+ 2
Python3: How do I get a While Loop print the input Answer if correct, elseif make the user try to answer again. Test code below:
Question1 = "Question 1) What\'s 2 + 2?" print(Question1) Answer1 = int(input()) while True: if Answer1 <=3: print(Answer1) print("Try again bozo!") continue if Answer1 >=5: print(Answer1) print("Come on, it\'s not that hard! Try one more time...") continue if Answer1 == int(4): print(Answer1) print("You did it!") break https://code.sololearn.com/cw39yc2O0jLo/?ref=app
4 Antworten
+ 9
Actually, the only thing you have to do is include the input into the loop, right below "while True:"
+ 6
It can handle it. You just have to provide all rhe input at once, in several lines. Like this:
2
3
6
7
4
+ 1
You're right, it does work - also tested this on my PC as well and it works perfectly, thank you!
0
Just like this? I don't think this apps interpreter can handle this, I'll try it on my PC
while True:
Answer1 = int(input())
if Answer1 <=3:
print(Answer1)
print("Try again bozo!")
continue