I want to make an insert on the List Comprehensions. I can do it?
t = ['test','tes']
x = ['1','2','3','4','5']
t.insert([0,i]for i in x)
I want to make an insert on the List Comprehensions. I can do it?
t = ['test','tes']
x = ['1','2','3','4','5']
t.insert([0,i]for i in x)
If the result you're looking for is something like this
['test', 'tes', [0, 'test'], [0, 'tes']]
The code is below:
t = ['test','tes']
x = ['1','2','3','4','5']
t.extend([[0,i]for i in t])
print t
You can do it in a list comprehension but it ends up doing extra work. Just do it in a for loop:
for thing in x:
t.insert(0, thing)
t = ['test','tes']
x = ['1','2','3','4','5']
out = t + x
your out put will be ['tes','test','1','2','3','4','5','6'] or something alone those lines. python allows you to concatenate strings
The ListItemLabel accepts only strings. I want to give it more than one element in a list, I use in ListItemLabel front str, but it does not do anything.
I do not know if it's the way you think
Python:
result_true = ListProperty([])
extra = self.viewedit.adapter.data
for edit in extra:
if edit['active'] == True:
app.result_true.append(edit['text'])
#app.result_true = (edit['text'])
print app.result_true
Kivy:
ListItemLabel:
text:str(ctx.edit)
Return:
['\xce\xbb\xce\xb9\xce\xb1\xcf\x83\xcf\x84\xce\xae \xce\xbd\xcf\x84\xce\xbf\xce\xbc\xce\xac\xcf\x84\xce\xb1', '\xcf\x83\xce\xbf\xcf\x85\xcf\x83\xce\xac\xce\xbc\xce\xb9', '\xcf\x84\xcf\x85\xcf\x81\xce\xaf']