0

I want the list items to be separated into their own strings. It would be something like this.

list = ['a', 'b', 'c']

---------?---------

string1 = 'a'
string2 = 'b'
string3 = 'c'
  • 1
    why would you do that? creating variables dynamically is not recommended, while using a list is the better option, which seems you are already using – Tomerikoo Aug 04 '19 at 15:24
  • look here: [How do I create a variable number of variables?](https://stackoverflow.com/questions/1373164/how-do-i-create-a-variable-number-of-variables) – Tomerikoo Aug 04 '19 at 15:25

1 Answers1

0

If you have fixed number of variables you may try this:

[string1, string2, string3] = ['1', '2', '3']
Dmitry Kuzminov
  • 6,180
  • 6
  • 18
  • 40
  • `string1, string2, string3 = ['1', '2', '3']` would be better. Your version is also creating a list object which will then be immediately discarded. – David Buck Aug 04 '19 at 15:36