the_list = [x for x in range(2, 3)]
range(2,3) → [2]
So the_list = [2]
do_the_mess(parameter)
variable += parameter[0]
This tries to increment variable, but inside the function we never declared variable as global.
Python will look for a local variable variable to increment, but it doesn’t exist yet.
UnboundLocalError: local variable 'variable' referenced before assignment
Correct answer: D. The code raises an unhandled exception
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
4ba36e7
1 month, 3 weeks ago