Hey guys!
So I am trying to do a program, and for the most part I have it down except for 1 part of it.
Basically, I want my function to continue to prompt a user to enter an integer number between 1 and 100 inclusive, until the user enters a invalid integer.
I have the program here:
And the output is as followed:
>>> assign2PartB()
Enter a number between 1 and 100 to continue: 19
The number you entered was: 19
Enter a number between 1 and 100 to continue: 99
The number you entered was: 99
Enter a number between 1 and 100 to continue: 0
The number you entered was: 0
The number you entered (0) was not between 1 and 100. Try again, please!
My question is, when I enter "0" how do I get my program to not show "The number you entered was: 0" but only show "The number you entered (0) was not between 1 and 100. Try again, please!"
Thanks so much in advance guys, I appreciate your help!
So I am trying to do a program, and for the most part I have it down except for 1 part of it.
Basically, I want my function to continue to prompt a user to enter an integer number between 1 and 100 inclusive, until the user enters a invalid integer.
I have the program here:
Code:
def assign2PartB():
x = 0
while x <= 100:
x = input ("Enter a number between 1 and 100 to continue: ")
printNow ("The number you entered was: " + str(x))
if x <=0:
printNow ("The number you entered (" + str(x) + ") was not between 1 and 100. Try again, please!")
>>> assign2PartB()
Enter a number between 1 and 100 to continue: 19
The number you entered was: 19
Enter a number between 1 and 100 to continue: 99
The number you entered was: 99
Enter a number between 1 and 100 to continue: 0
The number you entered was: 0
The number you entered (0) was not between 1 and 100. Try again, please!
My question is, when I enter "0" how do I get my program to not show "The number you entered was: 0" but only show "The number you entered (0) was not between 1 and 100. Try again, please!"
Thanks so much in advance guys, I appreciate your help!
Comment