I have a list which contain names of students. Example: Read more
You can simly use a for loop with append to list. list1 = ['lion', 'dog', 'cat', 'tiger', 'cat', 'cat', 'zebra'] list2 = ['monkey', 'tiger', 'cow', 'mouse'] my_list = [] for animal in list1: #iterating over list1 if animal not in list2 and animal not in my_list: my_list.append(animal) #add item to tRead more
You can simly use a for loop with append to list.
[crayon-6763eee9e0d33858087462/]
[crayon-6763eee9e0d36278912089/]
kind regards
See less
You can use Counter if you want to do multiple count of the list from collections import Counter list = ['Jones','Adams','Frank','John','Lopez','Jones','Smith','Ivan','Julian','Carlos','Adams','Frank','Jones','John','Ivan'] print(Counter(list)) Result: Counter({'Jones': 3, 'Adams': 2, 'Frank': 2, 'JRead more
You can use Counter if you want to do multiple count of the list
See less[crayon-6763eee9e0bad332380378/]
Result:
[crayon-6763eee9e0bb1857082296/]