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
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
Comments
Leave a comment