n=int(input("enter amount of values : "))
a=[]
for i in range (n):
a[i]=int(input("number: "))
I don't know why python does some bad things happen around there can someone explain or show correct way.
That doesn't work
I'm not sure but I think you can use append
to append thing on list.
Code:
n=int(input("enter amount of values : "))
a=[]
for i in range (n):
a.append(int(input("number: ")))
print(a)
Output:
enter amount of values : 5
number: 3
number: 6
number: 2
number: 10
number: 6
[3, 6, 2, 10, 6]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.