How to read digits before the decimal point + only three digits after the decimal point.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Suleymanov

1st problem >> I need my “speedometer” label to show only the first digits until the decimal point.

Instead of “N.nnnnnn” I need “N”.

What do I need to change in my current code? >> SpeedoLabel.text = str(speed)

2nd problem >> I need my “lap time” label to show the digits before the decimal point and also only 3 digits after the decimal point.

Instead of “N.nnnnnn” I need “N.nnn”.

What do I need to change in my current code? >> LapTimeLabel.text = str(time)

Thank you for your time!

:bust_in_silhouette: Reply From: Suleymanov

Found the way! >> .pad_decimals("the number of decimals you want to keep")

Here’s how it’s done:
Solution to my 1st problem) >> SpeedoLabel.text = str(speed).pad_decimals(0)
Solution to my 2nd problem) >> LapTimeLabel.text = str(time).pad_decimals(3)