Skip to content

Instantly share code, notes, and snippets.

@graphicagenda
Created October 4, 2020 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphicagenda/c2cbc666ac3423f92d94b653bcd143a8 to your computer and use it in GitHub Desktop.
Save graphicagenda/c2cbc666ac3423f92d94b653bcd143a8 to your computer and use it in GitHub Desktop.
Code Wars Kata: Numbers in Expanded Form
# https://www.codewars.com/kata/5842df8ccbd22792a4000245/train/python
def expanded_form(num):
num = list(str(num))
store = []
for i in range(len(num)):
x = int(num[i])
if x > 0:
store.append(str(int(x * ( 10 ** (len(num) - int(i) - 1)) )))
return ' + '.join(store)
print(expanded_form(70304))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment