feat: completed problem-10.py
This commit is contained in:
+11
-1
@@ -1,2 +1,12 @@
|
||||
# Write a Python program that executes a list operation and handles an AttributeError exception if the attribute does
|
||||
# not exist.
|
||||
# not exist.
|
||||
|
||||
# Define a list and set it to 'demo_list' var
|
||||
demo_list = ['a', 'b', 'c', 'd']
|
||||
# Try a non-existent method on the list var (madeupmethod)
|
||||
try:
|
||||
demo_list.madeupmethod()
|
||||
# Handle the expected AttributeError
|
||||
except AttributeError:
|
||||
# Print error message
|
||||
print('That method is not valid')
|
||||
Reference in New Issue
Block a user