Skip to content

Instantly share code, notes, and snippets.

@CodeArtisT75
Created August 25, 2020 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeArtisT75/4eae834df828236a20b1e0b9f8e71c88 to your computer and use it in GitHub Desktop.
Save CodeArtisT75/4eae834df828236a20b1e0b9f8e71c88 to your computer and use it in GitHub Desktop.
SokanAcademy: Python - find number game
from random import randint
# initiale min and max is 1 - 99
minNum = 1
maxNum = 99
# this while loop will run until the num == YOUR NUMBER
while True:
# generate random number between min and max and print it
num = randint(minNum, maxNum)
print("your number is: " + str(num))
# get the answer from user
print("is it correct? k=less, b=greater, d=found")
answer = input()
# check answer and:
# if answer == 'k' the maxNum will be set to num
# if answer == 'b' the minNum will be set to num
# if answer == 'd' the while loop will break
if answer == "k":
maxNum = num
elif answer == "b":
minNum = num
elif answer == "d":
break
# Just print a success message
print("HOORAY! i found your number :))")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment