Write a Python function which receives 3 lists as its input parameters and combines the lists and remove repeated numbers from the combined list and return the combined list. For instance, if the input is [1,2,3,4,2,3] and [3,4,6,7] and [-1,0,23,4] the result is [1,2,3,4,6,7,-1,0,23] - Note, the order the lists are combined together does not matter. Use main function.
def merge3(list1,list2,list3):
L=[list1,list2,list3]
flattened=[i for subList in L for i in subList]
newL=[]
for i in flattened:
if i not in newL:
newL.append(i)
return newL
def main():
print(merge3([1,2,3],[1,2,4,5],[5]))
print(merge3( [1,2,3,4,2,3], [3,4,6,7], [-1,0,23,4]))
main()
Get Answers For Free
Most questions answered within 1 hours.