I think I may have cracked this for you. If not, then I'm sure you can make any adjustments. If not, then I'm more than happy to help you.
Try it by coding in your text.
{edit}
I Think we posted at almost the same time there. If this is any use to you, then cool; if not, maybe someone else can learn something from it.
Try it by coding in your text.
#!/usr/bin/python3 import re def fdigit(d): digit = re.search('\d',d) if digit: lst_string = re.split('\d',d) return lst_string[-1] string = "" # put your text in this string object lst_string = string.split(' ') pstring = '' for get_word in range(len(lst_string)): word = lst_string[get_word] check = fdigit(word) if not check: pstring += word+' ' else: pstring += check+' ' print(pstring)I'm not 100% happy with my function name, now that it's doing a slightly different job to the one that it was conceived for, but it'll do.
{edit}
I Think we posted at almost the same time there. If this is any use to you, then cool; if not, maybe someone else can learn something from it.
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein