How to get the first two digits after the decimal point of a float number in Python

1 Answer

0 votes
d = 3376.237150

s = str(d)

point_pos = s.index('.')

print(s[point_pos + 1:point_pos + 1 + 2])


'''
run:

23

'''


 



answered Sep 18, 2024 by avibootz
...