Typo in Variable Name: "weapon.strip()" Should Be "fruit.strip()" in List Comprehensions Example
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from trekhleb/learn-python
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
trekhleb/learn-python#104 · 1 comment ·
-
Learning Python Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
trekhleb/learn-python#108 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
trekhleb/learn-python#107 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
trekhleb/learn-python#106 ·
-
Hack Open
Difficulty 5/5 Over a week Newbie friendliness 1/100
trekhleb/learn-python#102 · 1 comment ·
All issues in trekhleb/learn-python
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100