Andres Deidan279 Points
Hello! I am very confused on how this code would run to output the letters. Can someone guide me step by step? Thanks!
Please guide me step by step as I am confused and stuck on this currently. Thanks!
Zimri Leijen6,955 Points
Assuming you mean this:
What would the output be of the following code?
print("A") try: result = 5 + 5 print("B") except ValueError: print("C") except TypeError: print("D") else: print("E") print("F")
It would go line by line.
First, it does `Print("A")
then it will
try: result = 5+5 print("B")
since there are no errors in this code, this code will run successfully
it will therefore execute
it will skip the
except statements because neither of those errors have been encountered, so it will resume at the
else block there's
finally there's a
print("F") command, that isn't in any of the blocks so that will always run.
hope that helps.