I have tried and errored a reasonable amount of times

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Aug 30 18:32:54 EDT 2014


On 30/08/2014 22:48, Seymore4Head wrote:
> On Sat, 30 Aug 2014 22:21:40 +0100, Mark Lawrence
> <breamoreboy at yahoo.co.uk> wrote:
>
>> On 30/08/2014 19:48, Tim Chase 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
>>>
>>
>> For the OP use the interactive prompt to see for yourself.  Compare:-
>>>>> 'no'.isupper
>> <built-in method isupper of str object at 0x0000000003D14FB8>
>>>>> 'no'.isupper()
>> False
>>>>>
> That would work now, but I didn't even know no.isupper() was command
> until 15 min ago.  :)
>
> I have been told that one is a method and the other calls a method.  I
> still have to learn exactly what that means.  I'm getting there.
>
> Thanks
>

Slow down a little :) 'no' is a string, isupper is just one of many 
methods that any string has.  Try typing help('no') into the interactive 
prompt and see what you get.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list