0

How can I name a list with the string value of an int? Example pseudo-code:

int i = 4;
list + i = [] // i want the name of the list to be thus 'list4'

1 Answers1

0

First of all, you don't declare type of variables in python, so i = 4 works just fine, also word "list" is reserved in python, so try to not use words which may collide with python built-ins. If you realy need to do that (which i don't recommend), you can achieve it by usin eval()

JJAACCEeEKK
  • 194
  • 1
  • 11
  • `eval('list' + str(i)) = []` gives can't assign to function call... –  Sep 17 '17 at 20:38