-
Notifications
You must be signed in to change notification settings - Fork 3
/
number_guessing.py
37 lines (33 loc) · 1.11 KB
/
number_guessing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import random
n = random.randint(1, 100)
count = 1
guess_chances = 10
player_name = input("Hey, What's ur name? ")
yes_words = ["yes","y","yeah","yup","yea","yep"]
no_words = ["no","nope","nah","not"]
print('Lovely to meet you! ' + player_name)
answer = input('Do You want to play guessing game with me? ')
answer = answer.lower()
if answer in no_words:
print('oh okay, maybe next time')
elif answer in yes_words:
print('Alright ' + player_name + ' I am thinking about a number between 1 and 100 and you have 10 chances to guess it ;D')
print('Lets get started')
while 1 <= guess_chances:
num = int(eval(input("Guess the number " )))
if num > n:
print('Your guess was too high: Guess a number lower than ', num)
elif num < n:
print('Your guess was too low: Guess a number higher than ', num)
else:
print('YOU WIN!')
print('You guessed the number in ' + str(count) + ' tries!')
break
guess_chances -= 1
print(guess_chances, 'Guesses Left')
count += 1
print("GAME OVER")
print("Number is ", n)
print('Thanks for playing :D')
else:
print('sorry, I didnt get it')