-2

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]?

Trees Jin
  • 13
  • 3

1 Answers1

1
 current_price = 1.158805
 
 print(str(current_price)[:-1])

Your output will be:

 >>> 1.15880
Ruggero
  • 427
  • 2
  • 10