Skip to content

Commit 7e6b604

Browse files
author
Vimal A R
committed
* Lists and item occurrences
1 parent 2d356fa commit 7e6b604

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎Day-111/list_count-2.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python3
2+
3+
# Compare the occurrences of items in a list
4+
def more_frequent_item(lst, item1, item2):
5+
if lst.count(item1) > lst.count(item2):
6+
return item1
7+
elif lst.count(item2) > lst.count(item1):
8+
return item2
9+
elif lst.count(item1) == lst.count(item2):
10+
return item1
11+
12+
print(more_frequent_item([2, 3, 3, 2, 3, 2, 3, 2, 3], 2, 3))

0 commit comments

Comments
 (0)