Starting search from rightmost column and moving left pandas I'm very new to pandas and I'm trying to implement the code to search for something on an excel spreadsheet.

Basically, the most recent price can be found on the furthest right column named "final cost", and that's what I need. However, there are multiple columns named "final cost" (as every invoice is posted on there).

What I currently have:

def find_most_recent(row_num: int, df) -&gt; float:
    k = -1
    checker = False
    while not checker:
        if df.columns[k] == "final cost":
            if not pd.isnull(df.iloc[row_num, k]):
                checker = True
                return df.loc[row_num, df.columns[k]]
        k -= 1


where row_num is the current row that is being searched, and df is the current dataframe being searched.

However, this gets only the first encounter of "final cost". For example, on a dataset of:



I want the return to be one of the prices in column L, but I'm getting returns of values from column F instead.

Any suggestions of a method to use?
Found the answer, putting 

if "final cost" in df.columns[k]:


instead of 

if df.columns[k] = "final cost":


seemed to have fix it