Created
November 14, 2025 13:15
-
-
Save lavafroth/1c8471988e3f185c6757e3674fcf2a1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test(fn): | |
| print(fn(tuple(map(str, range(0))))) | |
| # assert fn(tuple(map(str, range(0)))) == '' | |
| print(fn(tuple(map(str, range(2))))) | |
| # assert fn(tuple(map(str, range(2)))) == '0 and 1' | |
| print(fn(tuple(map(str, range(4))))) | |
| # assert fn(tuple(map(str, range(4)))) == '0, 1, 2, and 3' | |
| print(fn(tuple(map(str, range(10))))) | |
| # assert fn(tuple(map(str, range(10)))) == '0, 1, 2, 3, 4, 5, 6, 7, 8, and 9' | |
| comma = lambda x: ", ".join(x[:-1]) + (x[-1:] and (x[:-2] and ", and " or " and ") + x[-1] or "") | |
| test(comma) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment