# Converting suffixes to integer

I've been working on something that scrapes the text off a site, compares it to the minimum and then prints the result. Here's what i'm working with:

``````class RobloxMessage:
def __init__(self):
self.headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'}
self.session = requests.Session()

def groupcheck(self, group_id):
url = "https://www.roblox.com/Groups/Group.aspx?gid=" + group_id
r = requests.get(url)
if 'Funds:' in r.text:
currency = r.text.split('<span class="robux" style="margin-left:5px">')[1].split('</')[0]
else:
return
if currency >= '50':
owner = r.text.split('<a style="font-style: italic;" href="https://www.roblox.com')[1].split('>')[1].split('<')[0]
else:
return
if owner == 'No One!':
print('https://www.roblox.com/My/Groups.aspx?gid='+group_id +'\nCurrency: ' + currency + '\$'
else:
return
``````

( yes i define what the variable 'group_id' is, gets random ids or the id that is chosen )

The currency has suffixes | ex: 1K, 1M, 1B, etc and I was wondering how you would convert it to a number without commas depending on its suffix. I tried everything, no solution so hopefully I can figure this out finally.

depending on the information you posted, I suppose that the string may vary like: 1, 2.3K, 5.8M, 7B (examples). To cast this suffixes in normal value you may use the following code, which construct the dict of suffixes and it's coefficients, then if value contains one of the suffixes, then multiply value on corresponding coefficient:

``````suffixes = {'K': 1000, 'M': 1000000, 'B': 1000000000}
value = '3.2B' #  for example
if value[-1] in suffixes.keys():
value = float(value[:-1]) * suffixes.get(value[-1])
``````

hope it helps

``````sizes_dict = {'B': 1, 'K': 1000, 'M': 1000000}