Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
mayank shah
946 Pointsthe program outputs "NONE" when running "play_again()" function
import random
secret_num = random.randint(1,10)
def game():
guess = 5
while guess:
try:
choice = int(input("Guess the number:\n>"))
except ValueError:
print("Error! 'Enter an integer'\n")
continue
if choice == secret_num:
print("Wow you guessed it correct the num is {}.".format(secret_num))
break
if choice < secret_num:
print("Too low for the secret num")
else:
print("Too high for the secret num")
guess = guess - 1
print("You have {} guess remaining.\n".format(guess))
def play_again():
while True:
again = input(print("Do you want to play again? Y/N\n"))
if again.lower() == 'n':
break
elif again.lower() == 'y':
game()
else:
print("Enter 'Y' to play again and 'N' to quit the game")
game()
play_again()
1 Answer
Krishna Pratap Chouhan
15,203 Pointsinput() need not to take a print() function.
try this...
again = input("Do you want to play again? Y/N\n")