0
RepeatCount = 5
for i in range(RepeatCount):
    Name = input("Enter name: ")
    Stat = input("Enter stat: ")
    VariableX = "Name = " + "

Instead of VariableX, it would be Variable1 on the first loop, Variable 2 on the next loop and would create the amount of Variables depending on the RepeatCount number.

I'd then like to be able to use the Variables outside of the loop.

How would I do this? Thanks.

  • 5
    Don't. Create a dictionary or list instead, and update it with name/value entries. There should be a good dupe target for this... – Carcigenicate Nov 10 '17 at 22:56
  • Sorry to bother you with this but wouldn't it be more efficient to just declare a list or an array or another data structure to store such values and then use them as you please? or is this something you just need to know for fun? :) – oetoni Nov 10 '17 at 22:58
  • 3
    Note, even though some answers in that dupe tell you how to do exactly what you're asking, you should *not* do that. Just use a dictionary. This is exactly their use case. There's almost never a reason to dynamically create variables. – Carcigenicate Nov 10 '17 at 23:00

0 Answers0