I have variables with values like 1.7m 1.8k and 1.2b how can I convert them to a real number value for example
1.7m = 1700000 1.8k = 1800 1.2b = 1200000000
I would define a dictionary:
tens = dict(k=10e3, m=10e6, b=10e9)
then
x='1.7m' factor, exp = x[0:-1], x[-1].lower() ans = int(float(factor) * tens[exp])
1.4m articles
1.4m replys
5 comments
57.0k users