import random
def guess (x):
random_number = random.randint(1,x)
guess = 0
while guess != random_number:
guess = int(input (f"Guess a number between 1 and {x}:"))
if guess < random_number:
print('sorry its lower than number guees again')
elif guess > random_number:
print('sorry its higher than number gues again')
print(f' yeah you find it its true number is {random_number}')
guess(10)
its not working i wacthed video and made same thinks but not working can some one explain to me
and input code not working probelly idk why but this code same with video i watched and its not working or what i did wrong huh input code not working because i added : to my code but i cant see it https://www.youtube.com/watch?v=8ext9G7xspg&t=1274s and this is video i watched
there is only one differance from the video its i changed ’ to " but both of them not working
You changed the indentation from what the video is using.
bro i fixxed it thx for help
can you delete my comment or idk
Why? Asking questions and getting help is perfectly normal when learning
because i fixed it I mean, it was a bit of a bummer, but anyway, I don’t want other people to waste their time for looking at fixed issue
You will not be the first person or last person to use inconsistent indentation in Python. Knowing to look at that is very useful to future readers.
import random
def guess (x):
random_number = random.randint(1,x)
guess = 0
while guess != random_number:
guess = int(input (f"Guess a number between 1 and {x}:"))
if guess < random_number:
print(‘sorry its lower than number guees again’)
elif guess > random_number:
print(‘sorry its higher than number gues again’)
else:
print(f’ yeah you find it its true number is {random_number}')
guess(10)
its game for other users