[Tutor] TypeError: can only concatenate list (not "str") to list
Jacob S.
keridee at jayco.net
Mon Jan 31 15:05:21 CET 2005
You can also do...
Umm, if you're going to make nmr and pbr the values you're printing, why are
you printing the values?
Nevermind, look at this instead. BTW, aren't rows the horizontal things on
tables?
nmr = nmrows[i]
pbr = cols[0]
print "%s\t%s" % (nmr,pbr)
> >nmr = nmrows[i]
>> pbr = cols[0]
>> print nmrow[i] +'\t'+cols[0]
>
> nmr = str(nmrows[i])
> pbr = cols[0]
>
> print nmrow[i]+'\t'+cols[0]
>
> will print what you want.
>
> k
> --- Srinivas Iyyer <srini_iyyer_bio at yahoo.com> wrote:
>
>> Hello group,
>> I am trying to print rows from two lists together:
>>
>> how can i deal with TypeError' where i have to print
>> a
>> list and a string.
>>
>> for line in pb: # tab delim text with 12 columns
>> cols = line.split('\t')
>> temp_seq = cols[7].split('\n') # extract 7thcol
>> seq = temp_seq[0].split(',') #splitting it by ,
>> for nm in seq:
>> for i in range(len(nmrows)):
>> if nm == nmrows[i][0] and nmrows[i][3] < cols[4]
>> and nmrows[i][4] > cols[5]:
>> nmr = nmrows[i]
>> pbr = cols[0]
>> print nmrow[i] +'\t'+cols[0]
>>
>>
>>
>> I tried the following also :
>>
>> I created an empty list outside for loop and tried
>> to
>> extend the elements of the list and string
>>
>> nmr = nmrows[i]
>> pbr = cols[0]
>> result.extend(nmr+'\t'+pbr)
>>
>> # result is the list i created. nmr is a list, and
>> pbr
>> is a string.
>>
>> can any one plaease help.
>>
>> thanks
>> Srini
>>
>>
>>
>> __________________________________
>> Do you Yahoo!?
>> The all-new My Yahoo! - Get yours free!
>> http://my.yahoo.com
>>
>>
>> _______________________________________________
>> Tutor maillist - Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 250MB free storage. Do more. Manage less.
> http://info.mail.yahoo.com/mail_250
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
More information about the Tutor
mailing list