Python Forum
How can I unite some elems in the list?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I unite some elems in the list?
#4
In [1]: list_ = ['did', 'is', 'not', 'come', 'will', 'kill', 'are', 'not']

In [2]: res = [" ".join(elements).strip() for elements in " ".join(list_).split("not") if elements]

In [3]: res
Out[3]: ['d i d   i s', 'c o m e   w i l l   k i l l   a r e']
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
RE: How can I unite some elems in the list? - by wavic - Jul-25-2017, 07:21 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020