I was trying to solve this problem:
Write a program that takes two lists and returns a list that contains all the elements of the first list minus all the common elements between the two lists.
The coding part is very simple. Here it is:
list1=input()
list2=input()
for i in list1:
if i in list2:
list1.remove(i)
else:
pass
print(list1)
The problem that I face here is that list1 and list2 are strings.
Take list1=‘[1,2,3,4]’.
I need to convert list1 to [1,2,3,4].
I tried split() and join() methods as suggested in How to convert list to string
but I failed.
How do I convert '[1,2,3,4]' to [1,2,3,4]?