On 8/30/14 2:50 PM, Seymore4Head wrote:
On Sat, 30 Aug 2014 13:48:09 -0500, Tim Chase
<python.l...@tim.thechases.com> wrote:

On 2014-08-30 14:27, Seymore4Head wrote:
I really tried to get this without asking for help.

mylist = ["The", "earth", "Revolves", "around", "Sun"]
print (mylist)
for e in mylist:

  # one of these two choices should print something.  Since neither
does, I am missing something subtle.

     if e[0].isupper == False:
         print ("False")
     if e[0].isupper == True:
         print ("True")

I am sure in the first , third and fifth choices should be true.
Right now, I am just testing the first letter of each word.

There's a difference between e[0].isupper which refers to the method
itself, and e[0].isupper() which then calls that method.  Call the
method, and you should be good to go.

-tkc

That works.
Thanks


Also, instead of:

    if e[0].isupper() == False:
    if e[0].isupper() == True:

use:

    if not e[0].isupper():
    if e[0].isupper():

It's clearer and reads better.

--
Ned Batchelder, http://nedbatchelder.com

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to