Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # beginning the forloop
- looping = True
- num = 76 # number that is correct
- # beginning the forloop by asking them if they want to guess.
- ans = input("Hello, this game is called 'Magic Number', all you have to do is guess my magic number, which is from 25-368. Do you want to guess?")
- if ans == 'yes':
- print("Cool, let's start.")
- elif ans == 'no':
- print("Okay, good-bye.")
- looping = False
- else:
- print("Sorry, I didn't quite catch that. Refresh and try again.")
- looping = False
- # takes them here after answering 'yes'
- while looping:
- print("Take a guess, but if you want to stop just type 'exit'.")
- answer = input()
- # if they do not want to play anymore.
- if answer == 'exit':
- print('Thank you for trying!')
- looping = False
- elif int(answer) > num:
- print("Oops! Your number is too high")
- elif int(answer) < num:
- print("Oops! Your number is too low")
- elif int(answer) == num:
- looping = False
- print("You won! 76 is the correct number, thanks for playing!")
- # if they type something weird.
- else:
- print("Sorry, I didn't catch that, try again.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement