问题描述:
Write Number in Expanded Form
You will be given a number and you will need to return it as a string in Expanded Form. For example:
expanded_form(12) # Should return '10 + 2'
expanded_form(42) # Should return '40 + 2'
expanded_form(70304) # Should return '70000 + 300 + 4'
NOTE: All numbers will be whole numbers greater than 0.
If you liked this kata, check out part 2!!
代码实现:
#codewars第十一题
def expanded_form(num):
my_str = str(num)
_length = len(my_str)
j = 0
res = ''
if _length == 1: return str(num)
for item in my_str:
_l