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.
# 2
def any_lowercase2(s):
for c in s:
if 'c'.islower():
return 'True'
else:
return 'False'
First. Returnes true only if the first letter in a string is lower.
In: any_lowercase1('Hello')
Out: False
Despite the string has lower symbols in it, function returnes False.
Second. Always returnes true.
In: any_lowercase2('HELLO')
Out: True
Despite the string has no lower letters al all, function returnes True.
Third. Returnes true only in the last character is lower.
In: any_lowercase3('hELLO')
Out: False
Despite the string has lower character in it, function returnes False.
Fourth. Correctly checks for lowercase letters in any position.
Fifth. Returnes true only if all symbols in the string are lower.
In: any_lowercase5('hELLO')
Out: False
The string contains lower letter, but function still returnes False, becourse it also contains upper ones.
Comments
Leave a comment