Apr-21-2018, 03:44 AM
i have a string with digits (possibly with a period) and something else at the end such as
'1234.5foobar'
. i want to extract and convert the number and get a string of what remains. if it were already a function, it would probably return a 2-tuple like (number,remaining_string). the use case goal is making a function that converts expressed time intervals in various fixed units such as '1wk1day3min5'
-> 691385
or '2m7s'
-> 127
or '1.1h'
-> 3960
. i know how to do this in single character steps as i have implemented this in C, before. i need the same thing in Python, now, and wonder if there is a shorter way using only what comes with Python (so i do not need to require the user of my code to install anything but Python, itself).
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.