I don't know if i am asking my question right, but i want to know if its possible for me to multiply two numbers, and place a decimal depending on the length of the number?
I am currently doing something like this
def multiply(input1, input1):
num = (input1 * input1)
if len(str(num)) == 4 and str(num).isdigit():
print(num)
return num
multiply(225, 10)
Instead of returning something like 2250, i will like to return something like 2.25k. Is there an inbuilt function in python to achieve this?
Thank you.
Now i am currently doing something like this
from __future__ import division
def multiply(string1, string2):
num = (string1 * string2)
if len(str(num)) == 4 and str(num).isdigit():
num = format(num/1000, '.2f')
print(num + "k")
elif len(str(num)) == 5 and str(num).isdigit():
num = format(num/1000, '.1f')
print(num + "k")
return num
multiply(225, 10)
How efficient is this?