I am a beginner, trying a simple question Write a Python program to find the list of words that are longer than n from a given list of words. Although I've solved it another way, I originally wrote this code and it stopped working after the input 4 (i.e. wrong output for input 5). I'd be grateful to have a logical explanation as to why python did this to me. Following are the lines of code (it may not be efficient):
lst= ['the','quick','brown','fox','afjibhjkvh','afkjbrjv','hscb','kejfbaejkbv','jadbvjkfbv']
n=int(input('Enter length of words'))
for i in lst:
if len(i)<=n:
lst.remove(i)
print(lst)