August 5th, 2004, 04:19 AM
help,very easy question i think
I have a list like this list =[aaa.123,bbb,456]
I want to split with "." and assin each part of list to a new list like mylist0 = [aaa,123] and mylist1 =[bbb,456]
so I do
i = 0
while i < len(list):
s = list[i]
But i got error "can't assign to operator".
Could anyone help me slove this problem?
August 5th, 2004, 07:55 AM
You cant create dynamic variables like that saddly. And in most cases i wouldn't even try since a list would be much easier to use etc. You should also note that in order to split a value it has to be a string; not a literal.
If you really want to declair dynamic variables then you should look at the exec keyword. Look for it in this page:
array = ['aaa.123', 'bbb.456']
for (index, value) in enumerate(array):
array[index] = value.split('.')
August 6th, 2004, 12:46 AM
Thank you very much.
Originally Posted by netytan