[Tutor] A very simple question
Kirby Urner
urnerk@qwest.net
Thu, 30 May 2002 08:55:45 -0400
On Thursday 30 May 2002 10:51 am, Raymond Hettinger wrote:
> def checkIfOnlyLower(list):
> for item in list:
> if not item[0].islower():
> return 0
> return 1
>
> Raymond Hettinger
Good answer, except avoid using 'list', a builtin type name, as the=20
name of a variable. Likewise don't use int, float, str or dict as=20
variable names (I realize Raymond is following the original=20
example closely to show the similarities, as well as differences).
A more complicated example would be:
def checklower(thelist):
=09from operator import add
=09return len(thelist)=3D=3Dreduce(add,[i[0].islower() for i in thelist])
=2E..but Raymond's is better, for one because it stops when the first
non-lower is encountered.
Kirby