Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5948993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:11:13+00:00 2026-05-22T17:11:13+00:00

http://pastie.org/1966237 I keep getting an unbound local error. I don’t understand why it occurs,

  • 0

http://pastie.org/1966237

I keep getting an unbound local error. I don’t understand why it occurs, if the program is running right, it should go straight into the second assignment of the print_et_list function within the main function, looping itself without actually looping. The program only quits using sys.exit() in the hey_user function.

I included the whole program for context, it isn’t too long. Let me know if you want to have a look at the text files I use in the program, however I’m sure it’s unlikely that it is the source of the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:11:14+00:00Added an answer on May 22, 2026 at 5:11 pm

    UnboundLocalError happens when you read the value of a local variable before you set it. Why is score a local variable rather than a global variable? Because you set it in the function. Consider these two functions:

    def foo():
        print a
    

    vs

    def bar():
        a = 1
        print a
    

    In foo(), a is global, because it is not set inside the function. In bar(), a is local. Now consider this code:

    def baz():
        print a
        a = 1
    

    Here, a is set within the function, so it’s local. But it hasn’t been set at the time of the print statement, so you get the UnboundLocalError.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am getting weird python bus error when building a web app. http://pastie.org/714569 i
Hey I have this code right here: http://pastie.org/534470 And on line 109 I get
My .plist and code to read it is described in http://pastie.org/605082 NSLog(@Test %@\n,[test valueForKey:@FirstName]);
i am making ajax calls with jquery like this http://pastie.org/860837 and sometimes i get
http://pastie.org/931617 is a link to the source code. If there is a better way
I am using this data here: http://pastie.org/3231052 - How can I display the key
I have pasted the example of what I need here : http://pastie.org/1005178 I have
Hey all, I am using http://pastie.org/966473 as a reference as all I need to
I've put this information into a pastie, but repeated it here (pastie link http://pastie.org/private/4vprzwhllqv35egrf8jzwg
When I type tar -cvf ~/changeset.tar --files-from ~/changeset.txt, It responds with this output: http://pastie.org/1071080

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.