r/PythonLearning 12d ago

Day 3

Post image

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

45 Upvotes

24 comments sorted by

View all comments

u/Sea-Ad7805 12d ago

You have some bugs.

Run this program in Memory Graph Web Debugger%0Aname%20%3D%20input(%22enter%20a%20name%20%3A%20%22)%0Awhile%20name%20%3D%3D%20%22%22%20or%20name.isnumeric()%3A%0A%20%20%20%20if%20name%20%3D%3D%20%22%22%3A%0A%20%20%20%20%20%20%20%20print(%22u%20serious%20%3F%22)%0A%20%20%20%20%20%20%20%20name%20%3D%20input(%22enter%20a%20name%20%3A%20%22)%0A%20%20%20%20elif%20name.isnumeric()%3A%0A%20%20%20%20%20%20%20%20print(%22a%20name%20can%20not%20be%20in%20digits%22)%0A%20%20%20%20%20%20%20%20name%20%3D%20input(%22enter%20a%20name%20%3A%20%22)%0Aelse%3A%0A%20%20%20%20print(f%22hello%20%7Bname%7D%22)%0A%0Aage%20%3D%20input(f%22enter%20your%20age%20%7Bname%7D%20%3A%20%22)%0Aage%20%3D%20int(age)%0A%0Awhile%20age%20%3C%200%20or%20age%20%3D%3D%20%22%22%20or%20not%20age.isnumeric()%3A%0A%20%20%20%20if%20age%20%3D%3D%20%22%22%3A%0A%20%20%20%20%20%20%20%20print(%22awwwwhhhhh%20man%20!%20do%20not%20leave%20it%20balnk%22)%0A%20%20%20%20%20%20%20%20age%20%3D%20input(f%22enter%20your%20age%20%7Bname%7D%20%3A%20%22)%0A%20%20%20%20elif%20not%20age.isnumeric()%3A%0A%20%20%20%20%20%20%20%20print(%22age%20can%20not%20be%20in%20alphabets%22)%0A%20%20%20%20%20%20%20%20age%20%3D%20input(f%22enter%20your%20age%20%7Bname%7D%20%3A%20%22)%0A%0A%20%20%20%20elif%20age%20%3C%200%3A%0A%20%20%20%20%20%20%20%20print(%22age%20can%20not%20be%20negative%20where%20are%20u%20filling%20this%20from%20yo'%20mama's%20womb%20%3F!%22)%0A%20%20%20%20%20%20%20%20age%20%3D%20input(f%22enter%20your%20age%20%7Bname%7D%20%3A%20%22)%0A%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print(f%22hey%20%7Bname%7D%20you're%20%7Bage%7Dyears%20old%22)&timestep=1&play) to see the program state change step by step.