I have a question related to a specific string being moved to new list.
IF I have list like [“hello”, “world”, “====”,“my”, “name”,“is”,“XXX”],
After “====”, the rest of the element will append to a new list
so there are two new lists,
listnew1 will store => [‘hello’, ‘world’]
listnew2 will store =>[‘my’, ‘name’, ‘is’, ‘XXX’]
How am I able to accomplish it, I have no idea, please help me. Thanks
lista= ["hello", "world", "====","my", "name","is","XXX"]
listnew1= []
listnew2=[]
for i in lista:
if "=" not in i:
listnew1.append(i)
else:
listnew2.append(i)
print(listnew1)
print(listnew2)
rightnow the output is:
[‘hello’, ‘world’, ‘my’, ‘name’, ‘is’, ‘XXX’]
[‘====’]
but i iwish to be like this
[‘hello’, ‘world’]
[‘my’, ‘name’, ‘is’, ‘XXX’]