I'm "learning" Python in a course on Coursera, but this lesson doesn't have any explanation and doesn't seem to work at all. As I'm so new, I have no idea what is even going wrong in order to fix it or even glean how it should work from the lesson.
a = 1
try:
b = int(input("Please enter a number to divide a"))
a = a/b
except ZeroDivisionError:
print("The number you provided cant divide 1 because it is 0")
except ValueError:
print("You did not provide a number")
except:
print("Something went wrong")
else:
print("success a=",a)
finally:
print("Processing Complete")
The lesson purports that this should output "success a=",a but instead it's just vomiting out Something went wrong / Processing Complete / Please enter a number to divide a [input box] and even when a number (let's say 2) is entered to the input box, it just terminates like Something went wrong / Processing Complete / Please enter a number to divide a 2 never actually printing the success. I've been over the lesson multiple times now and there's nothing to indicate why it's not working. Since Coursera has no way to contact instructors, I have no recourse except to outsource their job to here. (Sorry)
EDIT: To clarify, this is a course lab that launches a Jupyter notebook with the code already populated, and we execute the code to see how it works. It's running Pyolite kernel. It has nothing to do with me not copying it correctly as it is pre-populated in the notebook. I do not know why it is not working, but it's frustrating because I don't know what correct is supposed to look like, or if this IS correct, why it's not working in the notebook that I simply launch and execute.