title: Is there a way to theoretically concatenate two names to make a variable name that is already defined?
body: <p>The objective of this code is basically to create dynamically named variables automatically at runtime, more specifically lists then loop through range of values based on how many lists I have then display them out as such. It seems to work when I define the variable I'm printing out as such</p>
  <pre><code>listNum = int(input(&quot;how many lists?: &quot;))
  for i in range(listNum+1):
      globals()[f&quot;my_list{i}&quot;] = []
  
  print(my_list0)
  </code></pre>
  <p>But when I try to loop through them so that I can display them it doesn't seem to work, giving me an error <code>NameError: name 'my_list' is not defined</code></p>
  <pre><code>listNum = int(input(&quot;how many lists?: &quot;))
  for i in range(listNum+1):
      globals()[f&quot;my_list{i}&quot;] = []
  
  for i in range(listNum):
      print(f&quot;{my_list}+{i}&quot;)
  </code></pre>
  <p>What may I be missing, because i'm trying to concatenate <strong>my_list</strong> with the value in the <strong>range</strong> so it can print out the variable that is there?</p>