Tuesday 27 August 2013

name not recognised as a list name

name not recognised as a list name

I have a list with a name:
list_123_456 = [1,2,3]
I then use some parts of a filename to recreate the name of this list:
name = 'list_{0}_{1}' .format(filename[0:3],filename[6:9])
This works to the extent that 'name' now equals 'list_123_456' as I wanted
it to. But the code is treating it as a string rather than as a list that
I defined at the beginning.
For example, if I try:
len(name)
I get the answer '12' (letters in the name) rather that '3' that I would
like.
Any help would be great, thank you.

No comments:

Post a Comment