我用 python 写了一个计数器代码,但我没有得到合适的结果。我通过输入数字制作了一个列表,然后想制作一个计数器并将计数器的结果发送到一个新列表中并打印它: 我该怎么做?
`>>>num1=int(input("plz enter a number: "))
>>>num2=int(input("plz enter a number: "))
>>>num3=int(input("plz enter a number: "))
>>>list1= [num1,num2,num3]
>>>for n in list1:
>>> n=n+1
>>> print(n)`
输入数字后的结果将是:
plz enter a number: 32
plz enter a number: 15
plz enter a number: 18
33
16
19
但我想在列表中看到 33、16、19。喜欢:
[33,16,19]
明月笑刀无情
相关分类