how to check if file exists pyuthon

import os
file_exists = os.path.exists("example.txt") # Returns boolean representing whether or not the file exists

Here is what the above code is Doing:
1. Importing the os module
2. Creating a variable called file_exists that stores the result of a call to the os.path.exists function
3. The os.path.exists function takes a string as an argument and returns a boolean representing whether or not the file exists