This is the task: Using while loop, if statement and str() function; iterate through the list and if there is a 100, print it with its index number. i.e.: "There is a 100 at index no: 5"
If I code like this -
lst = [10, 99, 98, 85, 45, 59, 65, 66, 76, 12, 35, 13, 100, 80, 95]
i = 0
while i < len(lst):
if lst[i] == 100:
print("There is a 100 at index no:", str(i))
i += 1
, then everything is fine but if I try using user inputted list instead of a set list the code is not working:
lst = input('Enter your nums:').split(',')
entered_data = list(lst)
i = 0
while i < len(entered_data):
if entered_data[i] == 100:
print("There is a 100 at index no:", str(i))
i += 1
I don't understand why is that so. Please, help.