Difference between a list comprehension and a for loop

前端 未结 5 1955
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-23 08:57
n=input()
y=n.split()
a=([int(x) for x in y])
print(a)

output

python .\\input_into_list.py
1 2 3
[1, 2, 3]

The above

5条回答
  •  滥情空心
    2021-01-23 09:34

    This is indentation error:

    n=input()
    y=n.split()
    for x in y:
        a=([int(x)])
        print(a,end=' ')
    

提交回复
热议问题