here is a function I wrote for a specific game. All of the other steps are correct but whenever I run this file, the consol says the line with print("it takes you", count, "tries") is "invalid syntax." does anyone have any idea why this may be the case? (I'm pretty sure the last print is aligned with the while loop).
def play_game():
''' Plays one interactive game of bulls and cows on the console'''
count=0
bulls=0
while bulls < 4:
guess = str(input("please guess the number"))
secret = str(bc.generate_secret())
if guess == secret :
print ("congratulations! you won the game!")
print ("it took you" + str(count) + "tries!")
else:
bulls=b_and_c.how_many_bulls(guess,secret)
count=count+1
print("the number of bulls is {}.".format(b_and_c.how_many_bulls(guess, secret)))
print("the number of cows is {}.".format((b_and_c.how_many_cows(guess, secret)))
print("it takes you", count, "tries")
Aucun commentaire:
Enregistrer un commentaire