Created
February 19, 2018 14:24
-
-
Save iamshadmirza/0bf6b6222377ae35560979a00316bb25 to your computer and use it in GitHub Desktop.
beginning with python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
cpunum = random.randrange(1,9) | |
usernum = 0 | |
count = 0 | |
print('guess a number between 1 and 9') | |
while True: | |
usernum = input() | |
count += 1 | |
if usernum== 'exit': | |
break | |
usernum = int(usernum) | |
if usernum < cpunum: | |
print("You guessed too low ") | |
elif usernum > cpunum: | |
print(" You guessed too high") | |
elif usernum == cpunum: | |
print("You guessed right in",count,"attempts") | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment