# variable x is available to you

x = 81.3242434534

#make x a string
y = str(x)

#remove the integer part of the float variable and round it up , up to the length of the string
decimal = round(x- int(x),len(y))

1 Like

Please provide the screen link and if it’s a question, change your topic tag into “Q & A” and specify the question.

Welcome to the community!

2 Likes

No need to convert to string type and then round up.

Just this would work

``````decimal = x - int(x)
``````

for instance :

x = 17.890980

decimal = x - int(x)

decimalfloat (<class ‘float’>)

0.890979999999999 —> not precise

My proposition reflects the decimal part accurately

Okay than try after correcting length `y` from your OP code

To

``````y = str(x).split('.')     # Calculate length of precision only
``````

So it would be

``````x = 17.890980
y = str(x).split('.')

decimal = round(x - int(x), len(y))
print(decimal)

0.89098
``````

I think this will work fine. 1 Like

sure ok ! string format upgraded 1 Like