May it’s very simple question, but I’m stuck here.
I have variable val as val="mandy", now i want to create a list whose name is the content of val. i.e. “mandy”. so how to define mandy=[] in python.
It’s like “$$” equivalent of PHP.
May it’s very simple question, but I’m stuck here. I have variable val as
Share
You can do something like this in Python, but it’s very un-Pythonic to do so (whereas it’s a common PHP idiom as I gather). Don’t use the language in a way it’s not intended to be used.
What you’re trying to do is much better done by using a dictionary, a maximally optimized datatype in Python: