Good day. I have code that converts results data frame to CSV. I have another code that in samae script that allows to name the csv file.When program runs user is asked to name the csv file and its generated.Question is how can i have a mechanism in the case that user enters the same name of an existing file stored in pycharm file that prompts the user that file name exists already and enter another one.
I have tried to use if statements that check if strings is equal to existing file without success.
filename=str(input('Insert file name'))
results=pandas.dataframe()
results.to_csv("%s.csv"%filename)
I expect the code to check when use inputs name to check in directory if file name already exists