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

2017-01-03 Thread cr2001
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.")




-- 
https://mail.python.org/mailman/listinfo/python-list


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

2017-01-05 Thread cr2001
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.")

-- 
https://mail.python.org/mailman/listinfo/python-list