Answer the question
In order to leave comments, you need to log in
How to enter the number of variables to set?
I want to write a program. I will describe the essence of what cannot be implemented.
The user enters a number in input(). N Next, the user is given the opportunity through input to set the values of N variables.
Example:
N = 2
then the user must enter the values of the variables n1 and n2. How to do it?
Answer the question
In order to leave comments, you need to log in
If I understand the task correctly, then you can add all the values to the array and then work with numbers from the array using indexes.
N=int(input('Введите количество переменных: '))
n=[]
for i in range(N):
n.append(int(input('Введите значение: ')))
print(n)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question