-
Notifications
You must be signed in to change notification settings - Fork 1
/
guess-the-number.py
64 lines (39 loc) · 2.15 KB
/
guess-the-number.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Create a program that guesses the number entered by the user.
print('Welcome to the Python Scripted Guessing Number Game. \n')
guessedNumber = 5
while True:
number = int(input('Please enter a number and I will guess that number: '))
if number > 0 and number <= 100:
if guessedNumber == number:
print(f'\nThe number you have entered is {guessedNumber}. \n')
askingUser = str(input('Am I right? (yes/no): '))
if askingUser.strip().lower() == 'yes':
print('\nThanks for playing with me, I am enjoying, lets play again! \n')
else:
print('No problem, please enter another number and I will guess that.')
elif guessedNumber < number:
print(f'\nThe number you have entered is {guessedNumber}.')
print(f'\nWas my guess one less than from the number ({number}) you have entered? \n')
askingUser = str(input('Am I right? (yes/no): '))
if askingUser.strip().lower() == 'yes':
print('\nOops! I was wrong, hard luck for me.')
askingUser = str(input('\nDo you want to play agaim? (sure/nope): '))
if askingUser.strip().lower() == 'sure':
print('\nGreat Decision!\n')
else:
print('No worries, its all up to you, wish you all the best!')
break
else:
print(f'\nThe number you have entered is {guessedNumber}.')
print(f'\nWas my guess one greater than from the number ({number}) you have entered? \n')
askingUser = str(input('Am I right? (yes/no): '))
if askingUser.strip().lower() == 'yes':
print('\nOops! I was wrong, hard luck for me.')
askingUser = str(input('Do you want to play agaim? (sure/nope): '))
if askingUser.strip().lower() == 'sure':
print('\nGreat Decision!\n')
else:
print('No worries, its all up to you, wish you all the best!')
break
else:
print('Please enter a number in range between 1 - 100.')