How can I write a function that show how many decimal places each float-3
value has. How would I be able to get that?
float1= 4.9778
float2 = 6.9987475673579
float3= 4567.1
Expected output:
4
13
1
How can I write a function that show how many decimal places each float-3
value has. How would I be able to get that?
float1= 4.9778
float2 = 6.9987475673579
float3= 4567.1
Expected output:
4
13
1
You should not use float as a variable name. You will be unable to use it if you want to create a float variable. Your problem is easy to solve. Just use this:
num = 124.178
tmp = len(str(num).split(".")[1])
print(tmp)