Hi, I have a problem with implementing a for loop for my program. I don't understand how to correctly make a for loop in asking the player to play again after getting the number right. The options should be yes as 1 and no as 2.
I have this so far...:
I have this so far...:
Code:
def playgame(): import random num = random.randint(1,10) guess = 0 score = 0 name= input(('Hi, what is your name?')) print('Hi', name,'. Try to guess my number from 1-10!') while(guess != num): guess = int(input('GUESS MY NUMBER!')) if(num < guess): print('You guessed..', guess) print('THE NUMBER IS TOO HIGH!') score = score+1 print ('Your score so far is..', score) if(num > guess): print('You guessed..', guess) print('THE NUMBER IS TOO LOW!') score = score+1 print ('Your score so far is..', score) if(num == guess): print('You guessed..', guess) print('YOU ARE CORRECT!') print('Your final score is..', score) playgame()
Comment