Created
September 29, 2014 12:12
-
-
Save alexnad/d3af923c30fe94b70e8b 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 dashInsert(num): | |
| new_str = '' | |
| previous_is_odd = False | |
| for number in str(num): | |
| if int(number)%2 == 1: | |
| if previous_is_odd: | |
| new_str += '-' | |
| previous_is_odd = True | |
| else: | |
| previous_is_odd = False | |
| new_str += number | |
| return new_str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment