The "while" command doesn't save itself
First, I just want to say I recently started with programming, so I'm not
very good. This is my problem:
x = int(input("Write a number between 1-100: "))
while x > 100:
x = int(input("The number must be less than 101: "))
while x < 1:
x = int(input("The number must be higher than 0: "))
else:
print ("The number is:",x)
There's a way to cheat the code by doing this:
Write a number between 1-100: 101
The number must be less than 101: 0
The number must be higher than 0: 101
The number is: 101
I basically don't want the user to be able to write a number higher than
100 or lower than 1.
I'm sorry for the bad explanation but I tried my best and, one again, i
recently started programming,
Thanks!
ps. I'm using python 3.3!
No comments:
Post a Comment