Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print ("Please think of a number between 0 and 100! ")
- high = 100
- low = 0
- ans = int((high + low)/2)
- print ("Is your secret number "+ str(ans) + "?")
- var = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly.")
- while var != 'c':
- if var == 'h':
- high = ans
- ans = int((high + low)/2)
- print ("Is your secret number "+ str(ans) + "?")
- var = input ("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly.")
- elif var == 'l':
- low = ans
- ans = int((high + low)/2)
- print ("Is your secret number "+ str(ans) + "?")
- var = input ("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly.")
- elif var == 'c':
- print ("Game over. Your secret number was: " + str(ans))
- break
- else:
- print('Sorry, I did not understand your input.')
- var = input ("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement