Recommendations for using the for command to get different numbers as inputs from for command
Question:
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.
Answers:
There are multiple solutions for your question, but here is one:
x = 5
x_list = []
for _ in range(x):
val = input()
x_list.append(val)
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.
There are multiple solutions for your question, but here is one:
x = 5
x_list = []
for _ in range(x):
val = input()
x_list.append(val)