You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try:
x = int(input('Enter the first number: '))
y = int(input('Enter the second number: '))
print(x / y)
except ZeroDivisionError:
print("The second number can't be zero!")
we will not get the :
TypeError: unsupported operand type(s) for /: 'int' and 'str'
if we give a "hello world!" as a 2nd number. Instead we will get that the typed input cannot be converted to int.
ValueError: invalid literal for int() with base 10: '"hello world!"
So the code on page 155 should be
try:
x = int(input('Enter the first number: '))
y = int(input('Enter the second number: '))
print(x / y)
except ZeroDivisionError:
print("The second number can't be zero!")
except ValueError:
print("Are you sure you typed an integer?")
The text was updated successfully, but these errors were encountered:
Since the program on page 151 is like so:
we will not get the :
TypeError: unsupported operand type(s) for /: 'int' and 'str'
if we give a "hello world!" as a 2nd number. Instead we will get that the typed input cannot be converted to int.
ValueError: invalid literal for int() with base 10: '"hello world!"
So the code on page 155 should be
The text was updated successfully, but these errors were encountered: