Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Raindrops]: Fixed Typo in itertools.compress Approach. #3808

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fixed typo in itertools compress approach.
  • Loading branch information
BethanyG committed Oct 31, 2024
commit ca8d150d5daef9934c9c3cf5755c88292928aa65
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If the 'sounds' string is empty, a string version of the number is returned inst
This is very succinct code that avoids string concatenation.
However, it does require the overhead of importing `compress()` from the [itertools][itertools] module.
The code is also harder to maintain should there be additional factors/sounds needed.
Because the factors and sounds are seperated, there is a chance mistakes could be made like forgetting a number or swapping which factor is paired with which sound.
Because the factors and sounds are separated, there is a chance mistakes could be made like forgetting a number or swapping which factor is paired with which sound.

A better approach for maintenance might be to turn the 'sounds' `tuple` into a dictionary where the factors and sounds can be stored separate from the logic that does the calculations and string creation:

Expand Down
Loading