Created
October 6, 2011 20:01
-
-
Save Rembane/1268487 to your computer and use it in GitHub Desktop.
Switch-case-statement in Python with default-statement
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
# Taken from row 21 in https://github.com/emilybache/Refactoring-Katas/blob/master/Tennis/python/tennis.py | |
result = { | |
0 : "Love-All", | |
1 : "Fifteen-All", | |
2 : "Thirty-All", | |
3 : "Forty-All", | |
}.get(self.p1points, "Deuce") | |
# The .get(key, default)-part returns the value with key key if found, else the default. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment