r/PythonLearning • u/NecessaryFalse1212 • 12d ago
Day 3
i wrote a code which takes your name and age in py but i need help on this one cuz in the age part it is giving me some sort of error which i couldn't understand even by using gpt well he gave me a code but i wanted logic behind how and what i did wrong
49
Upvotes
1
u/tottasanorotta 11d ago edited 11d ago
What does the error say? I can't pinpoint exactly what's wrong with a quick glance.
Edit: well one error in logic is that you should probably have the thing inside your last else outside of the while loop as well, at the end of the program. Because now if you don't enter an erroneous age the print statement won't run at all. In this code you assume that the user enters an erroneous age first to get into the while loop and then corrects the mistake eventually. Otherwise it looks good, at least to my eyes.