I have a function that creates and prints a Dataframe based on the contents of a file:
import pandas as pd
def DataFrameConverter(file):
    T = pd.read_fwf(file, header= None, names=['1','2','3','4','5','6','7','8','9'])
    T = T.rename(index={0:'A',1:'B',2:'C',3:'D',4:'E',5:'F',6:'G',7:'H',8:'I'})
    df = pd.DataFrame(T)
    print(df)
and a function that is supposed to allow the user to modify a DataFrame, by replacing 'X' values with user input:
def modifyDF(variable):
    while df.isin(['X']).any().any():
        
        print('')
        x = input('row: ')
        y = input('col: ')
        v = input('value: ')
        print('')
        
        df.loc[x,y] = v
        print(df)
Now I want to ask the user for a file name, read the DataFrame, and ask the user to modify it. I tried calling the conversion function and saving the result like so:
variable = DataFrameConverter(file = input('File name: '))
and then passing it like so:
modifyDF(variable)
However, I get errors saying that df is not defined. What is wrong with the code? How can I make modifyDF use the DataFrame that was created by DataFrameConverter?
 
     
    