[Tutor] Question

Aaron Klein aklein85 at yahoo.com
Sat Oct 3 17:14:14 EDT 2020


Hi,
I'm learning Python and am confused by nesting 'while' loops. My program should ask the user if they'd like to play again after guessing the number correctly. I'm not sure what variables to use in the outer loop. Do I create new ones? Thankd in advance for any suggestions!


import random
#seed random numberrandom.seed()
#prime loopcount = 1

while():    #prime nested loop    guess = int(input('Guess a number between 1 and 10\n'))    num = random.randint(1, 10)    while(guess != num):        guess = int(input('Guess a number between 1 and 10\n'))        count+=1    print('It took', count, 'guesses to guess correctly.')playAgain = str(input('Would you like to play again?\n'))


More information about the Tutor mailing list