[Tutor] Programming Question
cimjls
cimjls at yahoo.com
Tue Sep 19 16:01:03 CEST 2006
Here is what I need to do:
Create an IF branching statement that will take the
users input from 1-10 and return the English word for
the number. (1 is One, 2 is Two, etc.) If the user
enters a value outside of the range of 1-10, display
an error message, and ask the user to enter a valid
selection.
Here is what I have so far:
# Print the word for a number 1-10 entered by the user
# If there is an incorrect value entered print an
error message
# and have them type in a correct value
print "\nThis program prints the English word for a
number entered between 1 and 10."
print "\nIf an incorrect value is entered you will get
an error message and be asked to enter a correct
value."
raw_input("\n\nPlease press enter to continue.")
number = int(raw_input("Please enter a number between
1 and 10: "))
if number < 1:
print "That is an incorrect number. Please try
again."
raw_input("Please enter a number between 1 and 10:
")
if number > 10:
print "That is an incorrect number. Please try
again."
raw_input("Please enter a number between 1 and 10:
")
elif number == 1:
print "One"
elif number == 2:
print "Two"
elif number == 3:
print "Three"
elif number == 4:
print "Four"
elif number == 5:
print "Five"
elif number == 6:
print "Six"
elif number == 7:
print "Seven"
elif number == 8:
print "Eight"
elif number == 9:
print "Nine"
elif number == 10:
print "Ten"
raw_input("\n\nPress the enter key to exit.")
How do I get it to work after an incorrect number is
entered? I am stuck on this and would appreciate and
help or suggestions?
Thanks,
Josh
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Tutor
mailing list