Python Forum
Help with try, except, else finally
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with try, except, else finally
#3
No, they're not.
Should I move them to surround the try block? and take them off where they are now?

Please see below? Shy

#User inputs math type
operation = input('''
Please type in the math operation you would like to complete:
+ for addition
* for multiplication
''')
#User inputs number
try:
number_1 = int(input('Enter your first number: '))
except Exception:
print: ("You have not input a number")

try:
number_2 = int(input('Enter your second number: '))
except Exception:
print: ("You have not input a number")

#If user chooses addition
if operation == '+':
print('{} + {} = '.format(number_1, number_2))
print(number_1 + number_2)


#if user chooses multiplication
if operation == '*':
print('{} * {} = '.format(number_1, number_2))
print(number_1 * number_2)
Reply


Messages In This Thread
Help with try, except, else finally - by Pytho13 - Mar-21-2021, 04:17 PM
RE: Help with try, except, else finally - by Pytho13 - Mar-21-2021, 05:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Am I a retard - else and finally blocks in a try statement RubenF85 6 2,790 Jan-12-2021, 05:56 PM
Last Post: bowlofred
  finally clause Skaperen 6 4,065 Jun-02-2019, 09:02 PM
Last Post: snippsat
  try, except, finally ? microphone_head 3 2,986 Apr-28-2019, 09:36 PM
Last Post: microphone_head

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020