0

I am trying to save multiple variable with for loop from a list, i tried the below method but it is not working . how can I achieve something like this?

I want something like this

x1 = ""
x2 = ""

list = ["car","bike"]
for x in range(1,3):
    for i in list:
        x{x} = i

so once the loop finish we can run

print(x1)

print(x2)

result

car bike

how can I achieve something like this in this method or any other method?

titan
  • 45
  • 6
  • 1
    Does this answer your question? [How do I create variable variables?](https://stackoverflow.com/questions/1373164/how-do-i-create-variable-variables) – Nahiyan Jul 09 '21 at 06:43
  • The short answer is: Don't do this. Use a `list` or a `dict` instead. – Selcuk Jul 09 '21 at 06:44

0 Answers0