Search code examples
pythonpython-3.xstrip

Need exctra last word in first line form below input


I need output for below input data using python 2.7

enter image description here

enter image description here


Solution

  • This should work for you:

    import re
    your_string = "reth10.890"
    number = re.findall("\d+\.\d+", your_string)
    requested_string = re.sub(number[0], '', a)
    print(requested_string)
    >>>'reth'
    

    If your string contains more floats you have to select the last one in number