Aug 2, 2020 09:08 AM
(This post was last modified: Aug 2, 2020 09:09 AM by Treasuretrio.)
Hey everyone, I'm trying to learn python and i'm going through the 'Automate the boring stuff with python' book right now, this was one of the sample projects, but for some reason it has a problem with my last line, i'm getting unexpected token errors and EOF errors after that. I'm expecting it to be a small dumb mistake but i've looked over it 100 times and cannot figure out what it is.
Code
#Guess the number game
import random
print('Hello what is your name?')
name = input()
print('Well, ') + name + ', I am thinking of a number between 1 and 20'
secretNumber = random.randomint(1, 20)
for guessesTaken in range(1, 7):
print('Take a guess.')
guess = int(input())
if guess < secretNumber:
print( name + ' Your guess is too low.')
elif guess > secretNumber:
print:(name + ' Your guess is too high.')
else:
break # this condition is for the correct guess
if guess == secretNumber:
print('Good job' + name + ('You guessed my number in' + str(guessesTaken) + ' Guesses')
else:
print('No the number I was thinking of was ' + str(secretNumber))
