Hello friends, I'm new here.
I am still a beginner but I am quite familiar with loops and while statement and have used it many times.
I'm trying a simple exercise but the result only shows when the number I type exists in the list, otherwise I get an error which I don't understand :
Thank you
I am still a beginner but I am quite familiar with loops and while statement and have used it many times.
I'm trying a simple exercise but the result only shows when the number I type exists in the list, otherwise I get an error which I don't understand :
list = [1,3,4,6,7] number = int(input("Pick a number : ")) i=0 while list[i] != number : if i < len(list) : i = i+1 else : print("your numeber has not been found") print(f"the position of your number is {i}")Could you please help me understand which part of my while statement is not correct ?
Thank you

Larz60+ write Nov-28-2021, 03:10 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.