Hey, I'm new to python so don't judge.

cr2001 cr2001 at hotmail.co.nz
Mon Jan 2 22:49:14 EST 2017


Im doing a new task from my teacher but i can't seem to find what is wrong with 
this code. Can anyone help?

#mynumber.py
# this game uses a home made function
import random

#think of a number
computer_number = number.randint(1,100)

#create the function is_same()
def is_same(target, number:
        if target == number:
            result="win"
        elif target > number:
            result="low"
        else:
            result="high"
        return result

# start the game
print("hello. \nI have thought of a number between 1 and 100.")

#collect the user's guess as an interger
guess = int(input("Can you guess it? "))
#Use our function
higher_or_lower = is_same(computer_number, guess)
#run the game untill the user is correct
while higher_or_lower != "win"
    if higher_or_lower == "to low"
         guess = int(input("Sorry, you are too low. Try again."))
    else:
        guess = int(input("Sorry your are too high. Try again."))

    higher_or_lower = is_same(computer_number, guess)

#end of game
input("Correct!\nWell Done\n\n\nPress RETURN to exit.")




More information about the Python-list mailing list