forked from INDHU-P/Basic_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguess.py
More file actions
25 lines (24 loc) · 666 Bytes
/
guess.py
File metadata and controls
25 lines (24 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def guesser():
import random
key = 0
print('Hi! What is your name?')
name = input()
number = random.randint(1, 50)
print('Well, ' + name + ', I am thinking of a number between 1 and 50.')
while key < 6:
print('Take a guess.')
guess = input()
guess = int(guess)
key = key + 1
if guess < number:
print('Your guess is too low.')
if guess > number:
print('Your guess is too high.')
if guess == number:
break
if guess == number:
key = str(key)
print('Good job, ' + name + '! You guessed my number in ' + key + ' guesses!')
if guess != number:
number = str(number)
print('Nope. The number I was thinking of was ' + number)