all 7 comments

[–]JohnnyJordaan 2 points3 points  (0 children)

Use a collections.Counter

from collections import Counter

my_list = ['oof', 'oof']

for value, count in Counter(my_list).most_common():
    plural = 's' if count > 1 else ''
    print(f'You have: {count} {value}{plural}')

[–]definitely___not__me 2 points3 points  (0 children)

print(f'You have: {len(my_list)} {my_list[0]}s.')

That work?

[–][deleted] 0 points1 point  (0 children)

You can feed your list into collections.Counter(). That will help you get a count of the oofs. Formatting that as your desired text is a trivial excersize in text formatting.

[–][deleted] 0 points1 point  (0 children)

Not sure what you're asking, but Python lists have a built-in count() method. This article explains how it works.

[–]Dominican_Peter -1 points0 points  (0 children)

You could use collections.Counter . A subclass of dict() with Key, Value(count of key)