Skip to content

characters_occurrence.py #71

Description

! /usr/bin/env python3

"""To find the number of times characters are repeated in a string """

from collections import Counter

Counter('abracadabra').most_common(3)

[('a', 5), ('r', 2), ('b', 2)]

The argument of most_common is the number of items to be returned

Default will return count for all characters

Counter('abracadabra').most_common(1)

[('a', 5)]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions