Python Forum
local variable 'l' referenced before assignment...
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
local variable 'l' referenced before assignment...
#3
Also, take a look at how much code you're repeating. That's just a recipe for errors. I would put all the letters in a dict:

letters = {letter: 0 for letter in 'abcdefghijklmnopqrstuvwxyz'}
Then you can loop over the letters and do the count update code once. You can also pass the dict as a parameter to your functions, solving the problem that sparkz_alot pointed out.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: local variable 'l' referenced before assignment... - by ichabod801 - Jan-21-2017, 02:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rounding exercise: UnboundLocalError: local variable referenced before assignment Drone4four 5 3,580 Sep-06-2020, 09:01 AM
Last Post: ibreeden
  UnboundLocalError: local variable 'a' referenced before assignment fad3r 3 16,647 Jun-20-2018, 05:43 PM
Last Post: nilamo
  why am I getting "local variable 'x' referenced before assignment"? wlsa 6 9,210 Jun-16-2018, 05:31 PM
Last Post: buran
  variable referenced before assignment Niko047 4 23,094 Aug-04-2017, 07:55 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020