I'm having an issue with this simple counter program:  import time counter = 0  def countup():   while counter &lt; 10:       counter += 1       print counter       time.sleep (1);   countdown();  def countdown():   while counter &gt; 0:       counter -= 1       print counter       time.sleep (1);   countup();  countup();   And the error I am getting is:      UnboundLocalError: local variable 'counter' referenced before   assignment   Does this mean that I need to define a counter variable inside each function? I have tried this, but it didn't work. I also tried a global variable at the start using: global counter = 0 but that didn't work either.  Apologies foor the noob question, I'm just a guy prodding a bit of python code.
How can I create or use a global variable in a function?  If I create a global variable in one function, how can I use that global variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?
"Where" in careers' search seems to be broken Let's say I want to find a company in Ontario, Canada. Ok, I navigate to company pages and type ON, Canada to Where in search:        but there are no companies in there. So why if I type just Canada it finds companies in ontario; and if I type specific area (ON, CA)  it doesn't find anything ? What can a soldier requisition and for how long? In the military rank feature it says the soldier can "requisition simple equipment or a horse for temporary use". What qualifies as simple equipment, any simple weapon or something less complex than a catapult?  Additionally, which part of the sentence is the "for temporary use referring to, the simple equipment and the horse or just the simple equipment? Why does exclamation mark within double quotes cause a Bash error? Please look at these commands:  $ notify-send SYNC TIME! $ notify-send 'SYNC TIME!' $ notify-send "SYNC TIME!" bash: !": event not found $   The first two commands produce a notification bubble as expected. The third gives the error shown.  and  $ echo SYNC TIME! SYNC TIME! $ echo 'SYNC TIME!' SYNC TIME! $ echo "SYNC TIME!" bash: !": event not found $   Here as well, the echo works for first two commands but not in the third.  More problems here (although I was not planning on using this): both notify-send "SYNC!TIME" and echo "SYNC!TIME" give bash: !TIME": event not found.  But both notify-send and echo work with "SYNC! TIME"  Can someone please explain why the bash: !": event not found error appears? How should a bot earn enough reputation to perform the actions necessary for that bot? I want to create this:  Note that wire lay chaotically, so spiral object not the same thing.  There is a cool way to do this task in 3ds max:  Basically he deform straight spline/curve and then bend it couple iterations (over 9000 degrees angle in max).   Blender can't bend that way with simple deform as I know, only up to 360 degree. Is there any other way to make wire wrapping similar to photo? If I have the following code:  MyClass pClass = new MyClass(); pClass.MyEvent += MyFunction; pClass = null;   Will pClass be garbage collected? Or will it hang around still firing its events whenever they occur? Will I need to do the following in order to allow garbage collection?  MyClass pClass = new MyClass(); pClass.MyEvent += MyFunction; pClass.MyEvent -= MyFunction; pClass = null; Posting a Solution of a problem that You faced to Help Newbies About an Hour ago, I faced a problem and tried different ways to solve it.  At last I was going to post my Question on Stack Overflow, but the last trick which came in my mind worked, and the problem got resolved.    Now, if I want to post that problem on Stack Overflow with the solution which worked for me, for the purpose to help other newbies to get their answer if they face the same problem, what is the proper way of posting such solution to a problem? This week I've read two news stories about two different camera lenses that can magnify things that are very far away.  The first is the , which is a point-and-shoot camera that costs $600, has an 83x optical superzoom lens ("the same field of view as a 2,000mm lens on a full-frame camera"), and lets you see the craters of the moon.  The second is the , which weighs 36 pounds, costs $180,000, and can take portraits of people a half mile away.  A non-photographer might ask, "Why would somebody spend their life savings on a gigantic telescope of a lens when you could take far away pictures with a handheld camera for 1/300th the price?"  Well, I am basically a non-photographer, and I would like to ask that question. What does the big one give you that the little one doesn't provide? I understand that small changes in lenses can make a big difference in size and price, but this seems to be of a different scale entirely.   What is going on with the optics of the lenses that makes the small one able to be so small and the big one have to be so...big?   I'm trying to get a basic intuition for what makes lenses different, and I realize I don't understand enough about how lenses work to even know how to compare these apples and watermelons. Simple homework question about normally distributed variables The question states:      Consider a set of random variables $X_i$, where $i=1,...n$. Each $X_i$ is   normally distributed with mean $0$ and variance $1$, i.e. $X_i$ are $\mathcal N(0,1)$.   What is the mean and the variance of the random variable $Y$, where   $Y=X_1+...+X_n$.   How do I do this? Allow converting comments to answers Multiple two pin multi-color LEDs pattern - how does this work? How should I setup separate MX records for a subdomain? Let's say I have a domain that I run a web application on, for example cranketywidgets.com, and I'm using  for handling email for people working on that domain, for example, support@ cranketywidgets.com, jane@cranketywidgets.com, joe@cranketywidgets.com and so on.  Google's own mail services aren't always the best for sending automated reminder emails, comment notifications and so on, so the current solution I plan to pursue is to create a separate subdomain called mailer.cranketywidgets.com, run a mail server off it, and create a few accounts specifically for sending these kinds of emails.  What should the MX records and A records look like here for this?  I'm somewhat confused by the fact that MX records can be names, but that they must eventually resolve to an A record. What should the records look like here?  cranketywidgets.com - A record to actual server like 10.24.233.214  cranketywidgets.com - MX records for Google's email applications  mailer.cranketywidgets.com - MX name pointing to server's IP address  I would greatly appeciate some help on this - the answer seems like it'll be obvious, but email spam is a difficult problem to solve. How closely can a game legally resemble another? Was Grand Moff Tarkin under Darth Vader's control? In A New Hope, we see Grand Moff Tarkin ordering Darth Vader around. Also, it was . It's uncertain whether he knew .  But considering that Darth Vader was a Sith Lord, and a Jedi before that, are we entirely sure he wasn't secretly controlling Tarkin through a Jedi Sith mind trick? Convert char to int in C# I have a char in c#:  char foo = '2';   Now I want to get the 2 into an int.  I find that Convert.ToInt32 returns the actual decimal value of the char and not the number 2.  The following will work:  int bar = Convert.ToInt32(new string(foo, 1));   int.parse only works on strings as well.    Is there no native function in C# to go from a char to int without making it a string?  I know this is trivial but it just seems odd that there's nothing native to directly make the conversion. How to access new colour schemes in version 10? I've found that while using Vim on Windows Vim saves the file, a .ext.swp file that's deleted on closing the Vim window and a .ext~ file.   I assume the .ext.swp file is a session backup in case Vim crashes. What's the purpose of the .ext~ file however? Is this a permanent backup file? It's annoying as I'd like to copy all the files I'm working on to my host, without these duplicates. How can I turn this off or, if it's there for a good reason, hide the files? I have a set of aerial images which I am trying to clip by their overlapping areas, for use in a more involved program I am writing.  Is there a command line based tool out there with an easy method for extracting the overlapping areas from a pair of images?  The images themselves do not have georeferencing, but they DO come with a shapefile containing bounding boxes of the image collects, as well as IMU data from image collection.  I know this may be difficult since the images will have slight perspective differences, but I was hoping it would still be possible--especially since I am trying to maintain and utilize these perspective differences for something else. pattern matching in vim Right at the beginning of the game, Meowth comes into your room and attempts to wake you up. At this point, I assume I have to press some button to get out of bed, but the D-Pad or A button doesn't do anything, nor any of the other buttons. How do I get out of bed to start the game?