34531/how-to-print-a-message-or-the-error-if-a-file-is-not-found
Can you let me know in case I would like to put a check condition for a file, in case the file is not available it should print "file is not available, please upload the file". How can I do this?
To print the message that file is not found, use try-except block.
Refer below sample code.
filename="C:/Users/Desktop/123456.txt" try: open(filename, 'r') except OSError as e: print("File " + filename + "is not available, please upload the file.")
a = int (input('enter number')) num = a sum ...READ MORE
n = int (input ('ENTER NUMBER TO ...READ MORE
Hello, For install biopyhton with proper instruction you can ...READ MORE
For Python 3, try doing this: import urllib.request, ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
Hi @Mike. First, read both the csv ...READ MORE
The right datatype for destination in argpasrse module ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.