Skip to content

characters_occurrence.py #71

@ghost

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)]

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