Skip to content

Hands on: A common generators pattern #2

@pberkes

Description

@pberkes

In the file 2_common_pattern.py [1], write a generator called without_punctuation that iterates over a list of strings and removes punctuation characters at the end of the string. If the string is empty after the removal, the string is skipped.

For instance, without_punctuation(['Apple', 'Banana...', 'Carrot!!', '*$', '!Dinosaur']) would yield Apple, Banana, Carrot, and !Dinosaur.

(see the .rstrip method of strings, and the constant punctuation in the module string)

[1] https://github.com/ASPP/2019-camerino-advanced-python/tree/master/notebook/generators/hands_on

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions