Question #280238

For each function, describe what it actually does when called with a string argument. If it does not correctly check for lowercase letters, give an example argument that produces incorrect results, and describe why the result is incorrect.

# 1

def any_lowercase1(s):

   for c in s:

     if c.islower():

        return True

     else:

        return False


Expert's answer

def any_lowercase1(s):
   for c in s:
     if c.islower():
        return True
     else:
        return False

The function actually checks if the first character is lowercase. So the call

any_lowercase1("AbCD")

returns False while it should return True


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS