SHOW:
|
|
- or go back to the newest paste.
| 1 | DAY_NAME_TO_ORDER = {
| |
| 2 | "monday": "first", | |
| 3 | "tuesday": "second", | |
| 4 | "wednesday": "third", | |
| 5 | "thursday": "fourth", | |
| 6 | "friday": "fifth", | |
| 7 | "saturday": "sixth", | |
| 8 | "sunday": "seventh" | |
| 9 | } | |
| 10 | ||
| 11 | - | g = raw_input("What day are you leaving on?? ")
|
| 11 | + | g = input("What day are you leaving on?? ")
|
| 12 | ||
| 13 | matching_days = filter(lambda x: x in g.lower(), DAY_NAME_TO_ORDER.keys()) | |
| 14 | ||
| 15 | # You wouldn't usually do this but I worte this example in python 2 | |
| 16 | # where filters return lists instead of iterators | |
| 17 | - | print("That's a {0} day of the week".format(
|
| 17 | + | matching_days = list(matching_days) |
| 18 | - | DAY_NAME_TO_ORDER[selected_day])) |
| 18 | + | |
| 19 | if len(matching_days): | |
| 20 | selected_day = matching_days[0] | |
| 21 | print("That's a {0} day of the week".format(DAY_NAME_TO_ORDER[selected_day]))
| |
| 22 | else: | |
| 23 | - | raw_input("PRESS ENTER TO CLOSE.") |
| 23 | + | |
| 24 | ||
| 25 | ||
| 26 | input("PRESS ENTER TO CLOSE: ") |