Jan-15-2021, 11:37 PM
(This post was last modified: Jan-15-2021, 11:38 PM by BashBedlam.)
What you want to do is pickup each character after 'AA=' as long as it's a number or a decimal point. Combine those into a string and then convert it to a float. Here is one way to go about that:
data = ['Line 1: 123 NUBA AA=1.2345 $BB=1234.55', 'Line 2: 123 NUBA MM AA=1.2345678&BB=1234.55', 'Line 3: 123 NUBA RRNJH AA=1.2#ALPHA'] ACCEPTIBLE = '123456789.' aa_numbers = [] for line in data : temp_number_string = '' marker = line.index ('AA=') + 3 while line [marker] in ACCEPTIBLE : temp_number_string += line [marker] marker += 1 aa_numbers.append (float (temp_number_string)) print (aa_numbers)