Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Typo in Variable Name: "weapon.strip()" Should Be "fruit.strip()" in List Comprehensions Example #105

Open
@Imran-imtiaz48

Description

In the function test_list_comprehensions(), under the list comprehension that cleans up whitespace from a list of fruit names, the variable weapon is used instead of a more context-appropriate name such as fruit. This can be confusing for readers and may lead to misunderstandings, as the list is called fresh_fruit and contains fruit names.

Current code:

fresh_fruit = [' banana', ' loganberry ', 'passion fruit ']
clean_fresh_fruit = [weapon.strip() for weapon in fresh_fruit]
assert clean_fresh_fruit == ['banana', 'loganberry', 'passion fruit']

Suggested change:
Change weapon to fruit for clarity and consistency:

clean_fresh_fruit = [fruit.strip() for fruit in fresh_fruit]

This will improve code readability and maintain consistency with the context of the example.

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

        AltStyle によって変換されたページ (->オリジナル) /