[Tutor] python help
trista rayment
tristarayment at yahoo.com
Sat Sep 12 11:35:53 EDT 2020
I need to write a code that asks for a number between 5 and 25 and only allows integers and if a non integer is entered it needs to print 'you must enter an integer' or if it types a number less than 5 or more than 25, it needs to re-ask the original question until it gets an appropriate answer
would it be better to form an else if or a range or is there a more effective function to put in my code?
my first thought would be:
print('Enter an integer between 5 and 25')howMany = input()
limit(int(num, minimum = 5, maximum = 25) else ValueError
if ValueError = print('Enter an integer between 5 and 25')
or
for howMany in range (5, 25) print(....
or
while howMany = (>=5, <=25): continue
else return
I can't seem to get to any usable code that makes sense to even me. And google, and my textbook aren't helpful with examples at all.
Please suggest something that should be completely obvious to me
Thank you!!
More information about the Tutor
mailing list