Cody Bable

Generation

generate functionThu, 20 Apr 2023

try...except block checking if a file exist

def check_file(file): try: with open(file, 'rb') as f: return True except IOError: return False check_file('file.txt')

Questions about programming?Chat with your personal AI assistant