I want to be able to get a list with a range of numbers 3 or higher, and turn it into a list of numbers of range 1 to 3 only. The code only removes some numbers above 3 and leaves others. I want all numbers above 3 removed from the list.
thelist= [1,8,9,2,3]
for element in thelist:
if int(element) >= 4:
thelist.remove(element)
elif int(element) <= 3:
continue
print(thelist)
# prints [1, 9, 2, 3]. Number 8 was removed but not number 9