| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Hi there! 👋🏽 Thanks for submitting this PR. 😄
I did do it on purpose, but my 'copypasta' got the better of me! It is more sound when using dict.items() to have the dictionary view unpack both the keys and the values (and then use them!). And that was my intent here -- to show an approach that was different looking, but the same as what is in the introduction.md summary: def convert(number):
#This is clear and easily added to. Unless the factors get
# really long, this won't take up too much memory.
sounds = {3: 'Pling',
5: 'Plang',
7: 'Plong'}
results = (sounds[divisor] for
divisor in sounds.keys()
if number % divisor == 0)
return ''.join(results) or str(number)Buuut. I copied the code above and missed modifying sounds[divisor]! 😱 Now that I am looking at all this again, I think perhaps the best thing to do is use the example above in the approach document, and use the code with dict.items() in the introduction.md. I'll update this PR with those changes, and you can let me know if it reads better to you that way. |
Sorry, something went wrong.
Swapped the two dictionary approaches and adjusted `introduction.md`, `Benchmark.py`, `Performance`, and the approaches doc accordingly.
|
Yes, looks even better. The distinguish between using items() and keys() adds even more knowledge to the already rich article! |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for giving this one last read-through! 🌈
Sorry, something went wrong.
Going to push the big, green button then! |
Sorry, something went wrong.
* dict-and-join simplify * Swapped dictionary approaches Swapped the two dictionary approaches and adjusted `introduction.md`, `Benchmark.py`, `Performance`, and the approaches doc accordingly. --------- Co-authored-by: BethanyG <BethanyG@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Probably this was done on purpose but as a way to discuss this I wanted to propose a little simplification to the approach.
I think this is more sound and readable to just use the item from the dict.
Let me know what you think.
Thanks in advance.