Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#105 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
82/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
documentation

Research direction

Search the repository for the test_list_comprehensions() function and inspect the list-comprehension example using fresh_fruit. Rename the local variable weapon to fruit, then run the relevant Python example or test if one is available and confirm the existing assertion still passes.

Written by the indexing model from the issue text.

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.

Dominant language
Python
Stars
18.3k
Forks
3k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from trekhleb/learn-python

All issues in trekhleb/learn-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.