Skip to content

Instantly share code, notes, and snippets.

@alexnad
Created September 29, 2014 12:12
Show Gist options
  • Select an option

  • Save alexnad/d3af923c30fe94b70e8b to your computer and use it in GitHub Desktop.

Select an option

Save alexnad/d3af923c30fe94b70e8b to your computer and use it in GitHub Desktop.
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