Convert float price to integer price without commas My payment gateway wants the prices this way: "1050" instead of 10.50.
So I created this function:

https://repl.it/HgHI/3

def price_format_gateway(price):
    price = "{0:.2f}".format(price)
    price = price.split(".")
    try:
      if len(price[1]) &gt; 2:
        decimals = str(price[1][0:2])
      else:
        decimals = price[1]
    except IndexError:
      pass

    return str(price[0]) + str(decimals)


price_format_gateway(10) # Expected -&gt; 1000
price_format_gateway(10.1) # Expected -&gt; 1010
price_format_gateway(10.15765) # Expected -&gt; 1016


Is there another way more elegant, or cleaner? I just want to improve.
For me at least, it would be more natural to think of the operation as a multiplication by 100:

def price_format_gateway(price):
    return '{:.0f}'.format(100 * price)