General FizzBuzz: Difference between revisions
Content deleted Content added
→{{header|Python}}: Changed last example to preserve order and duplicate moduli; changed variable names in previous example. |
m →{{header|Python}}: Removed unnecessary import and empty line; changed order in example output. |
||
Line 1,563: | Line 1,563: | ||
'''Another version, using ranges with step 3, 5, etc. Preserves order and duplicate moduli.''' |
'''Another version, using ranges with step 3, 5, etc. Preserves order and duplicate moduli.''' |
||
<lang Python>from collections import defaultdict |
<lang Python>from collections import defaultdict |
||
n = 100 |
n = 100 |
||
Line 1,595: | Line 1,595: | ||
print(fizzbuzz(n, mods)) |
print(fizzbuzz(n, mods)) |
||
</lang> |
</lang> |
||
{{Out}} |
{{Out}} |
||
<pre> |
<pre> |
||
>>> mods = [ |
>>> mods = [ |
||
⚫ | |||
... (2, 'Two '), |
... (2, 'Two '), |
||
... (6, 'six '), |
... (6, 'six '), |
||
... ( |
... (8, 'eight... '), |
||
... (6, 'HA! SIX!'), |
... (6, 'HA! SIX!'), |
||
⚫ | |||
... ] |
... ] |
||
>>> print(fizzbuzz(16, mods)) |
>>> print(fizzbuzz(16, mods)) |