forked from CodecoolBP20172/pbwp-3rd-si-code-comprehension
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcomprehension.py
More file actions
33 lines (23 loc) · 744 Bytes
/
comprehension.py
File metadata and controls
33 lines (23 loc) · 744 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
25
26
27
28
29
30
31
32
33
import random
guesses_taken = 0
print('Hello! What is your name?')
myName = input()
number = random.randint(1, 20)
print('Well, ' + myName + ', I am thinking of a number between 1 and 20.')
while guesses_taken < 6:
print('Take a guess.')
guess = input()
guess = int(guess)
guesses_taken += 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:
guesses_taken = str(guesses_taken)
print('Good job, ' + myName + '! You guessed my number in ' + guesses_taken + ' guesses!')
if guess != number:
number = str(number)
print('Nope. The number I was thinking of was ' + number)