List problem

kevndcks at aol.com kevndcks at aol.com
Thu Aug 24 18:29:04 EDT 2006


For example i write the following code in the Python command line;

>>>list = ['One,Two,Three,Four']

Then enter this command, which will then return the following;

['One,Two,Three,Four']


Now the problem, reading through the Python tutorial's, it describe's
that list's can sliced, concatenated and so on etc

So i write the following

>>>list[1:] + ['Five']

Then the error returned is that 'str' and 'list' could not be
concatenated which is where it baffles me. I'm understanding that this
mean's that the string 'Five' could not be joined onto the list, as i
havn't defined it in the array. Viewing the Python tutrial they have
the following, and working code;

>>> a[:2] + ['bacon', 2*2]
['spam', 'eggs', 'bacon', 4]

How can they have the string 'bacon' and have it returned with no
error?




More information about the Python-list mailing list