I am a beginner and have started learning python.I am supposed to make a program in which the user has to guess a random number between 1 and 100. If the guess is not correct then it's fine else I'm supposed to display message such as :"You're guess is far from the number " or if the guess is within 10 units of range of the number , I should display message such as You're 10 units in range of the number.
Now I'm dealing with a kind of logical error here .To explain this,if the random number is 42 and the user enters 32,the message displays :"You're 10 units in range of the number." which is fine but when I enter 32 ...It displays again:"You're 10 units in range of the number."
What should i do in the if-else to fix the code.I need to display if user is in range of 10 units to the umber to be guessed else I must print you're far from the guess.
from random import *
from time import *
number= randint(1,100)
print(number)
start=time()
guess=0
while guess!=number:
guess=int(input())
if number-guess <=10 :
print("you are in range of 10 units to the number to be guessed.")
else:
print("You are very far in guess from that number.")
elapsed=time()-start
print("Time taken to guess the number correctly is ",elapsed)

abs(number - guess). Else 20 - 80 = -60 <= 10.from random import *but writeimport randomorfrom random import randint.abs(number - guess)so the distance is always positive