I have a long string, which is basically a list like str=\"lamp, bag, mirror,\"
(and other items)
I was wondering if I can add or subtract some items, i
If you have two strings like below:
t1 = 'how are you'
t2 = 'How is he'
and you want to subtract these two strings then you can use the below code:
l1 = t1.lower().split()
l2 = t2.lower().split()
s1 = ""
s2 = ""
for i in l1:
if i not in l2:
s1 = s1 + " " + i
for j in l2:
if j not in l1:
s2 = s2 + " " + j
new = s1 + " " + s2
print new
Output will be like:
are you is he