Skip to content

Instantly share code, notes, and snippets.

View asadamatic's full-sized avatar
🎯
Focusing

ASAD HAMEED asadamatic

🎯
Focusing
  • Islamabad, Pakistan
  • 14:24 (UTC +05:00)
View GitHub Profile
@asadamatic
asadamatic / si_to_int.py
Last active February 16, 2020 07:51 — forked from gajeshbhat/strToInt.py
Convert k to Integer thousand Python.
def convert_si_to_number(x):
total_stars = 0
if 'k' in x:
if len(x) > 1:
total_stars = float(x.replace('k', '')) * 1000 # convert k to a thousand
elif 'M' in x:
if len(x) > 1:
total_stars = float(x.replace('M', '')) * 1000000 # convert M to a million
elif 'B' in x:
total_stars = float(x.replace('B', '')) * 1000000000 # convert B to a Billion