# Write Number in Expanded Form - Part 2
This is version 2 of my ['Write Number in Exanded Form' Kata](https://www.codewars.com/kata/write-number-in-expanded-form).
You will be given a number and you will need to return it as a string in [Expanded Form](https://www.mathplacementreview.com/arithmetic/decimals.php#writing-a-decimal-in-expanded-form). For example:
```python
expanded_form(1.24) # Should return '1 + 2/10 + 4/100'
expanded_form(7.304) # Should return '7 + 3/10 + 4/1000'
expanded_form(0.04) # Should return '4/100'
```
def expanded_form(num):
    num = str(num)
    index = num.index('.')
    leng = len(num) - index - 1
    num = num[:index] + num[index + 1:]
    ans1 = ' + '.join(num[i] + (index-i-1) * '0' for i in range(index) if num[i] != '0')
    ans2 = ' + '.join(num[i+index] + '/1' + (i+1) * '0' for i in range(leng) if num[i+index]!='0')
    return ans2 if not ans1 else ans1 + ' + ' + ans2
def expanded_form(num):
    num = str(num)
    index = num.index('.')
    leng = len(num) - index - 1
    num = num[:index] + num[index + 1:]
    ans1 = ' + '.join(num[i] + (index-i-1) * '0' for i in range(index) if num[i] != '0')
    ans2 = ' + '.join(num[i+index] + '/1' + (i+1) * '0' for i in range(leng) if num[i+index]!='0')
    return ans2 if not ans1 else ans1 + ' + ' + ans2