Python’s list: What is the difference Between methods Append and Extend?

Here in this tutorial, We will discuss What is the difference between Python’s list methods append and extend? As both are used for adding elements in existing mutable lists in Python Ways To Add Elements In An Existing List At times we need to add some elements to an existing list whereas at some times … Read more

Some Basic Python List Programs-3

Some Basic Python List Programs-3

Python program to remove duplicates from a list list1 = [2, 6, 9, 8, 4, 8, 6, 6, 5, 7, 2, 4] #using list comprehension list2 = [] [list2.append(ele) for ele in list1 if ele not in list2] print(list2) #Output: [2, 6, 9, 8, 4, 5, 7] #using list comprehension and enumerate() list3 = [ele … Read more

%d bloggers like this: