Q:

Python Data-Scraping Differentiation - millions vs. ones

I'm currently scraping some tables on the internet where numbers are posted in varying numerical formats:
Animal - Left in Wild
Tigers - 18
Deer - 18m
Pigs - 180000

I've managed to strip the m away from the number, but I am wondering if/how I could use a if statement to allow some manipulation to ensure I document the number accurately:
if animal.strip("m") == animal.strip("m"):
    left_in_wild = left_in_wild * 1000000

Obviously that code does not work, but it is a rough thought of how I'm thinking about getting around this. If anyone can has anything they think can be helpful let me know.
Thank you!

A:

A simple IF statement could help with what you're looking for:
animal = "18m"

if 'm' in animal:
    print animal.strip('m') + ",000,000"

if 'k' in animal:
    print animal.strip('k') + ",000"

returns:
18,000,000

