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?
#3
I have resolved it so:
list_ = ['did', 'is', 'not', 'come', 'will', 'kill', 'are', 'not']
for x in list_:
   if x == 'not':
       something = list_.index(x) -1
       newelem = list_[one] + ' not'
       list_.pop(one)
       list_.remove(x)
       list_.insert(one, newelem)
print(list_)
Reply


Messages In This Thread
RE: How can I unite some elems in the list? - by Mike Ru - Jul-24-2017, 05:04 PM

Forum Jump:

User Panel Messages

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