Skip to content

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

Open

Description

@Imran-imtiaz48

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.

Activity

  1. xy769 commented on May 11, 2026

    @xy769

    Hi @trekhleb, just checking in on this PR — is there anything I can do to help get it merged? Happy to make adjustments if needed. Thanks!

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