May-30-2020, 07:28 AM
hi :) i am starting to learn python, and learning from Automating Boring Stuff With Python, then i tried to implement the knowledge and do something by myself.
i am creating this program that asks user for the age. when i tested the program, i realised if i didn't enter the number correctly as integer, the program would not continue.
so i tried to create a condition for the program to check whether it is integer or not, if not, the user can type again, and then the program would print 'thank you', and continue to print the calculated value, and continue until the end.
however, i am caught up for a lengthy period, so i think i should post a question to ask someone knowledgeable, here are my codes :
i am creating this program that asks user for the age. when i tested the program, i realised if i didn't enter the number correctly as integer, the program would not continue.
so i tried to create a condition for the program to check whether it is integer or not, if not, the user can type again, and then the program would print 'thank you', and continue to print the calculated value, and continue until the end.
however, i am caught up for a lengthy period, so i think i should post a question to ask someone knowledgeable, here are my codes :
print('hello there') print('what is your name?') myName = input() print('your name is ' + myName + ', it is nice to meet you') print('the length of your name is composed of ' + str(len(myName)) + ' letters.') print('what is your age?') myAge = input(int()) if myAge == input(int()): print('thank you') else: print('please enter the number only') while myAge != int(): print('please enter the number only') myAge = input(int()) print('thank you') print('you will be ' + str(int(myAge) + 1) + ' next year') print('this is the end of this program')thank you :)