'Python NameError: name 'ind' is not defined

i ma trying to subtract the index of dataframe ddd1 obtained by the if condition from the last index of teh dataframe ddd. The indices are timestamp values. But on running the program, it shows NameError: name 'ind' is not defined. What is the issue? '''

m_dict = {}    
for key,val in period_dict.items():
    p_key = period_dict[key]
    second_day = p_key.index[1]
       
    ddd = data.loc[:second_day]
    ddd1 = ddd[::-1]
    
    
    for index,row in ddd1.iterrows():
        if row['Rainfall(mm)'] != 0:
            # print(index)
            ind = index
            break

    m = (ddd.index[-1] - ind).days   
        
    p_key['m'] = m
      
    m_dict.update({key:p_key})

'''



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source