Home > Back-end >  Recommendations for using the for command to get different numbers as inputs from for command
Recommendations for using the for command to get different numbers as inputs from for command

Time:09-11

I’ve have just started to learn python and wanted to know if there was a way to, by using the command for obtaining an x amount of inputs that I can use to do a formula. I’ve tried using

for i in range(x):#n=number_of_inputs_I-want
    x = int(input())

My problem relies in the fact that I don’t know how to make the computer store these inputs in different variables so that I can use them for a math formula. thank you for all the help you may provide.

CodePudding user response:

There are multiple solutions for your question, but here is one:

x = 5
x_list = []
for i in range(x):
    val = input()
    x_list.append(val)
  • Related