feat: completed problem-05.py
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# Write a Python program that opens a file and handles a PermissionError exception if there is a permission issue.
|
# Write a Python program that opens a file and handles a PermissionError exception if there is a permission issue.
|
||||||
|
# Try opening 'filename2.txt' (file created with 000 permissions as to trigger exception
|
||||||
try:
|
try:
|
||||||
open('filename2.txt')
|
open('filename2.txt')
|
||||||
|
# Handle expected PermissionError exception
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
|
# Print error message
|
||||||
print('Insufficient file permissions')
|
print('Insufficient file permissions')
|
||||||
|
|||||||
Reference in New Issue
Block a user