Jul-16-2023, 08:36 AM
Maybe some simple doubling function?
def double(text): doubled = [] carry = 0 for num in text[::-1]: if num in ('.', ','): doubled.append(num) else: quotient, reminder = divmod(2 * int(num), 10) doubled.append(str(reminder+carry)) carry = quotient if carry: doubled.append(str(carry)) return ''.join(doubled[::-1]) for num in ("1", "10", "12.5", "1.9", "99", "99.7899", "99.999"): print(f"{num}, {double(num)}") 1, 2 10, 20 12.5, 25.0 1.9, 3.8 99, 198 99.7899, 199.5798 99.999, 199.998
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.