I have the variable
current_price = 1.158805
But I need to limit to 5 numbers (in this case I want the current price to be 1.15880), what can I do?
I need a general solution because the variable changes every second.
And what if I have the numer in a pandas dataframe, for example data.close.iloc[-1]
?
CodePudding user response:
current_price = 1.158805
print(str(current_price)[:-1])
Your output will be:
>>> 1.15880