#dawsnon
#chapter 3, task 4
#Computer is guessing...
#4
import random
n = int(input('User enters number: '))
rand = -1
edge1 = 1
edge2 = 100
rand = random.randint(edge1, edge2)
print("My guess is ...\n", rand)
while rand != n:
if rand > n:
print("Ah, alright, it was lower than ",rand )
edge2 = rand
elif rand < n:
print("Nope, a little higher than ",rand)
edge1 = rand
rand = random.randint(edge1, edge2)
print(rand)
print("You guessed it right!")
Единственный косяк, random может генерировать несколько одинаковых чисел подряд