I have the number 4.476
for example and I’d like to expand that like 4 + 4/10 + 7/100 + 6/1000
. There is my code below
t = []
count = 0
dec = str(n).split('.')
for i in dec[0]:
t.append(i)
for j in dec[1]:
t.append(j + "/" + str(10 ** (len(dec[1])-count-1)))
count += 1
print(' + '.join(t))
But that doesn’t work at all