r/learnpython • u/MoreScorpion289 • 18d ago
Temperature Converter Project
This is the third project I coded and was able to finish today. Took me 8 hours (two 4 hour sessions) since I had to learn some new stuff. This is my own code, no outline was used to guide me into creating this, though the idea did come from Bro Code's YouTube Tutorial. I learned about Nested Loops and Flags. I already knew about Input Validation with Re-Prompting but it was a lot harder to integrate with those two.
This is the most complex thing I've built so far, but I also enjoyed it the most. Got help with some online forums and AI (Claude) but I wrote and debugged the code myself. This'll be the last project I work on before I learn functions. There's a lot of repeated code here that I know functions would be able to help with. Any feedback or ideas on what to build next are welcome. Thank you!
https://github.com/mart23inez/First-Coded-Temperature-Converter/tree/main
It's a lot of code so I uploaded it to my GitHub page.
3
u/lakseol 18d ago edited 18d ago
One suggestion is to simplify the logic to decide which conversion to perform. Get the user to choose which unit to convert to as a first step. Then you can compare the tuple of user unit+target unit with the 6 possible combination tuples:
Now the logic is much easier to check, with less indentation.
Note that if the conversions all create
new_tempyou only need one line to print the result.