Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- chance = 0
- print('Hello! What is your name?')
- myName = input()
- magic_number = random.randint(1, 20)
- #print(magic_number)
- print('Well, ' + myName + ', please enter a number between 1 and 20.')
- while chance < 5:
- print('Take a guess')
- user_input = input()
- user_input = int(user_input)
- if 20 >= user_input >= 1:
- #print("valid number")
- chance = chance + 1
- if user_input == magic_number :
- print('Good job, ' + myName + ' You guessed the number' )
- if chance == 1:
- print("you won 50 points")
- elif chance == 2:
- print("you won 40 points")
- elif chance == 3:
- print("you won 30 points")
- elif chance == 4:
- print("you won 20 points")
- elif chance == 5:
- print("you won 10 points")
- break
- elif user_input < magic_number:
- print('Your guess is too low.')
- elif user_input > magic_number:
- print('Your guess is too high.')
- else:
- print("Invalid number")
- break
- else:
- magic_number = str(magic_number)
- print('sorry the number is ' + magic_number)
Add Comment
Please, Sign In to add comment