On 16/10/15 23:31, zak nelson wrote:
I don't understand why this program is said to be "not defined" when I test
it.

In future please be more precise in describing the problem,
and that means including the full error message in the post.
It contains a lot of useful information.

I'm guessing it doesn't say that the program is not defined
but it says the name buler is not defined? Is that correct?

Notice the spelling?
Now look at your code

def problem22(aList):
     length=len(aList)
     if (length>6):
         bueler=False
     else:
         bueler=True
         for i in aList:
             if(i < 0 and i > 6)==False:
                 bueler=False
             else:
                 buler=True
                 if type(i)!=("integer"):
                     bueler=False
                 else:
                     bueler=True
     return bueler

But there are a couple of other issues in there too.
Specifically this line:

          if(i < 0 and i > 6)==False:

The bit in parentheses can never be true because i can
never be both <0 and >6 at the same time. So the if
statement is always true and the next line is always
executed.

Also the line

   if type(i)!=("integer"):

Will never be true because the string 'integer' is not a type.
You should use the type name:

   if type(i) != int

or compare to the type of a known value:

   if type(i) != type(5):

In the case of an int the first one would be better.
A final refinement is that for these kinds of comparisons
it probably reads better to use is/is not rather
than the ==/!= symbols, so:

   if type(i) is not int:

HTH

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to