QuestionQ64Verified/Functions and ExceptionsCopy linkReport a problemAsk AstroTutorSave questionWhat is the expected outcome when the following code is run? AThe code prints 2BThe code prints 1CThe code prints 0DThe code raises an unhandled exception.Show AnswerAnswerExplanationIn Python, an augmented assignment to a name inside a function makes that name local to the function unless it is declared global or nonlocal. variable += parameter[0] attempts to read that uninitialized local variable first, causing an UnboundLocalError that is not handled.Show comments0Show commentsCommunity DiscussionNo comments yet. Be the first to start the discussion!
Community Discussion