feat: completed problem-10.py
This commit is contained in:
@@ -15,5 +15,5 @@ dividend = 93
|
|||||||
# and a value to divide by
|
# and a value to divide by
|
||||||
divisor = 0
|
divisor = 0
|
||||||
|
|
||||||
|
#Call the function with defined vars
|
||||||
divide(dividend, divisor)
|
divide(dividend, divisor)
|
||||||
+11
-1
@@ -1,2 +1,12 @@
|
|||||||
# Write a Python program that executes a list operation and handles an AttributeError exception if the attribute does
|
# 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