简体   繁体   中英

How do I make n-amount of inputs in a for-loop and use all the inputs later?

Here there are a "num" amount of inputs. How do I get the nth input value?

num = input("How many values?")

for x in range(0, int(num)):
    ok = input()

Store inputs in list.

num = input("How many values?")
ok=[]
for x in range(0, int(num)):
    ok.append(input())
print(ok)

And for nth value:

ans = ok[n-1]

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM