python列表删除问题

python列表删除数据问题

img

ls=int,input().split()
n=int(input())
for i in range(n+1):
    if n in ls:
        ls.remove(n)
        print(ls)
    else:
        print('NOT FOUND')

报错:
期望输出:[1, 3, 4, 5]
我的输出:NOT FOUND

ls = list(map(int,input().split()))
n = int(input())
if n in ls:
    while ls.count(n)>0:
        ls.remove(n)
    print(ls)
else:
    print('NOT FOUND')

ls=map(int,input().split())
你这种写法不是把input转换为int,而是把int作为一个元素放到了ls里