Mar-08-2019, 01:55 PM
Hello! So my teacher wants up to take out duplicates from a list that the user puts. This is my code:
My teacher gave us this but I don't quite understand it, or how to even incorporate it into my code, and if anything I might not:

num=int(input("First List- How many elements do you want?: ")) lista=list() for i in range(num): element=int(input(" Input a number: ")) lista.append(element) num=int(input("Second List- How many elements do you want?: ")) listb=list() for i in range(num): element=int(input(" Input a number: ")) listb.append(element) print "This is your new list: " listc=list() listc=lista+listb listc.sort() print listcSo basically, if listc's output is
Output:[2,2,3,5,5,8,9]
because the user may have put the same numbers twice, then we need to take out the duplicates so it then becomes this instead. Output:[2,3,5,8,9]
My teacher gave us this but I don't quite understand it, or how to even incorporate it into my code, and if anything I might not:
new=lista for i in listc: m=listc[0] if m not in new: new.append(m)Anyways, thank you if anyone answers, I appreciate it.
