def convert(text):
    t = int(text)
if t < 1000:
    return str(t) + ' us'
elif t < 1000000:
    return str(int(t / 1000)) + ' ms'
elif t == 1000000:
    return '1 sec'
Best way to incrementally convert microseconds to their respective conversions in python?