Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Python problem

Name: Anonymous 2013-10-24 4:14

I keep on getting this error:

Traceback (most recent call last):
  File "C:\Users\XXXXX\Desktop\Python\easer.py", line 70, in <module>
    for i in YEARS[1982:]:
NameError: name 'YEARS' is not defined

I have a list which is this:

YEARS = [1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048]

I don't understand it not being defined.I mean the list is correct unless the values have to be strings.

Name: Anonymous 2013-10-24 4:16

Name: Anonymous 2013-10-24 4:43

use perl

Name: Anonymous 2013-10-24 5:02

Python
Now you have two problems.

Name: Anonymous 2013-10-24 6:19

>>1
You're missing two of the years, by the way.

Name: OP 2013-10-24 11:22

Which ones I see all of them?

Name: Anonymous 2013-10-24 13:06

>>4
>le homophile sage

Name: Anonymous 2013-10-27 10:16

>for i in YEARS[1982:]:
(I'm going off of this because you posted no code sample)
Call me crazy, but unless YEARS has 1983 elements and I just can't count, that's your problem.

Name: Anonymous 2013-10-27 18:08

>>8
but then it should just be an empty loop, instead of a "YEARS undefined" error
but I agree that OP should post his code

Name: Anonymous 2013-10-27 23:13

You should post your code. Because it could be something as simple as YEARS being defined inside a function that you didn't call, or being inside a loop due to not proper indentation and you're so tired of looking at the code that you can't see it.

Name: Anonymous 2013-10-27 23:54

One word: Forced Indentation Of Code

Name: Anonymous 2013-10-28 2:29

YEARS = list(range(1982, 2049))# This is better, than a hard coded list.

for i in YEARS : # There is probably no need for slicing here.
# Unless you need a shallow copy of the list, in which case do <YEARS[:]>.

Traceback (most recent call last):
  File "C:\Users\XXXXX\Desktop\Python\easer.py", line 70, in <module>
    for i in YEARS[1982:]:
NameError: name 'YEARS' is not defined # This error depends on how your scope is set up. I'd need to see more code as to tell you exactly why.

Don't change these.
Name: Email:
Entire Thread Thread List