How to get float?

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

print(float(1))
1

Why not 1.0?

try printing float(0.1) instead

rustyStriker | 2018-02-13 13:54

:bust_in_silhouette: Reply From: Zylann

You are getting a float. You don’t get .0 because there is no need to show any decimals.

Suddenly suddenly :\

Tort | 2018-02-13 14:09

:bust_in_silhouette: Reply From: literalcitrus

If you really want to display 1.0 then look into using format strings. For your example use print("%.1f" % float(1)).