2/21/25, 11:31 AM Untitled2.
ipynb - Colab
import random
from getpass import getpass
num1 = int(input('Enter the lowest number you would like to play with: '))
num2 = int(input('Enter the highest number you would like to play with: '))
print('I am thinking of a number between ' + str(num1) + ' and ' + str(num2) + ', inclusive. Guess the number!')
guess= int(getpass('enter your guess here: '))
actualnum = random.randint(num1,num2)
guesslist = []
def play(guess):
while guess != actualnum:
if guess in guesslist[0:]:
print('you already guessed that!')
guess = int(getpass('try again: '))
continue
guesslist.append(guess)
low = False
high = False
if guess > actualnum:
high = True
print('too high')
else:
low = True
print('too low')
if low or high:
guess = int(getpass('try again: '))
if guess == actualnum:
print('you got it! the number was '+str(actualnum)+'!')
play(guess)
https://colab.research.google.com/drive/1wHuRwvaFYpwYUXYJds_f94n1okb8bas9 1/1