Questions & Answers
When testing for specific failure types (ZeroDivisionError & ValueError) if you enter 0 for the numerator it still lets you enter a denominator before giving u the error. My assumption is because it hasn't actually executed the division yet but let me know. However, if you enter a letter for the numerator if instantly gives u the value error, why is that? does it check to see if you entered an int since that's what it's expecting? Thanks!
try:
num1 = int(input('Enter the numerator: '))
num2 = int(input('Enter the denominator: '))
result = num1 / num2
print(f'The result is: {result}')
except ZeroDivisionError:
print('Error: Cannot divide by zero.')
except ValueError:
print('Error: Please enter valid numbers.')
finally:
print('Execution of the try-except block is complete.')
👾