Good day,
I am trying to use a list of integers and strings, take certain elements out, and concatenate them into a string.
i.e.
What I am wanting this to print would be:
XX 0 f 0 XX
What I am getting is:
Do I need to convert this into tuples of the length desired, or is there a different way?
I am trying to use a list of integers and strings, take certain elements out, and concatenate them into a string.
i.e.
Code:
lista = [0,'f',0,1,1,1,0,'a',8] split_length = 3 stringa = '' while split_length >= 0:[INDENT]print 'XX ',[/INDENT][INDENT]for idx in lista:[/INDENT][INDENT][INDENT]stringa = stringa + str(lista[idx]) + ' ',[/INDENT][/INDENT][INDENT]print 'XX'[/INDENT]
XX 0 f 0 XX
What I am getting is:
Code:
XX Traceback (most recent call last):[INDENT]File "<stdin>", line 4 in <module>[/INDENT] TypeError: list indices must be integers, not str
Comment