syntax - Python NameError -


list1 = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]  item in list1:     print item 

not sure why above code throwing error:

nameerror: "name 'a' not defined" 

in addition using quotes properly, don't retype alphabet.

>>> import string >>> string.ascii_lowercase 'abcdefghijklmnopqrstuvwxyz' >>> l = list(string.ascii_lowercase) >>> print l ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', ... >>> help(string) 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -