Last active
August 29, 2015 14:19
-
-
Save darthShadow/0bd70448a1928b68624e to your computer and use it in GitHub Desktop.
This file contains 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
# Author : Anagh Kumar Baranwal | |
# Question : http://www.practicepython.org/exercise/2014/04/02/09-guessing-game-one.html | |
import random | |
rand_num = random.randint(1,9) | |
count = 0 | |
while(1): | |
choice = input("Please enter the number OR 'exit' to exit : ") | |
if(choice == "exit"): | |
print("You guessed "+str(count)+" times") | |
break | |
else: | |
num = int(choice) | |
if(num == rand_num): | |
print("Exactly Right") | |
elif(num > rand_num): | |
print("Too High") | |
count+=1 | |
elif(num < rand_num): | |
print("Too Low") | |
count+=1 | |
else: | |
print("Enter valid integer") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment