Why do i need to type no twice to get my end printout for my dice roll game? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why do i need to type no twice to get my end printout for my dice roll game?

from random import * print("Welcome! Type yes or no to roll the dice!") while input() == "yes": print("Dice roll is: ", randint(1, 6)) print("Would you like to roll again?") if input() == "no": print("Thanks for playing!")

17th Apr 2019, 3:09 AM
Inaloop
Inaloop - avatar
1 Answer
+ 4
You code asks for an input in the while loop, but it doesn't assign it to any variable, so the value is "lost". Then, it asks for another independent input in the if condition.
17th Apr 2019, 3:58 AM
Diego
Diego - avatar