Oct-23-2019, 05:53 AM
(This post was last modified: Oct-23-2019, 05:57 AM by Sandeep2000.)
I am not getting expected output? Why?
I want program to remove characters from plist which are not in qlist list.
phrase="don't panic" plist=list(phrase) str1="on tap" qlist=list(str1) for item in qlist: if item not in plist: plist.remove(item) print(plist)Output:
Output:['o', 'n', 't', ' ', 'p', 'a', 'n', 'c']
Desired output:I want program to remove characters from plist which are not in qlist list.
Output:['o', 'n', “‘”, 't','p', ‘a’, ‘n’]