T
T
TreShk02018-03-07 16:55:39
Python
TreShk0, 2018-03-07 16:55:39

How to add unknown variables in Python?

How to add unknown variables? For example, there is a code

for l in nawz:
    locals()[l] = input("Enter number: ")

Where the nawzperson enters the list himself. These variables are not known, but you need to perform various arithmetic operations with them. Is it possible to check it and how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-03-07
@AlexNineteen

nawz = []
N = input() // количество элементов в массиве
for i in range(int(N)):
    inpt = input()
    nawz.append(inpt) // добавляем введённый человеком текст в массив

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question