+ 1

How can i dynamically create variables in python3?

what i want is, something like this, for x in range(1,6): variable'x' = input() in place of x there will be numbers and i'll have variables from variable1 to variable5.

29th Jun 2018, 5:21 PM
Milind Yadav
Milind Yadav - avatar
1 Respuesta
+ 2
How about using lists? my_inputs = [input() for x in somerange] my_inputs[3] # some input or with dictionaries... my_inputs_dict = {'var'+str(i) : input() for i in somerange} my_inputs_dict['var3']
29th Jun 2018, 5:43 PM
Qwertiony
Qwertiony - avatar