I define the function to accept a list of strings as its argument, so that I can then call the function and give it lists of strings which start with both upper and lowercase letters. I want to use the .isupper method with conditional statement(s) to return only strings that have uppercase letters from the string list arguments.
def find_upper(strlist):
for i in strlist:
if "i".isupper() == True:
print(i)
break
else "i".islower() == True:
continue
find_upper(['Marco', 'Billy', 'Petey Pelican', 'Chip Block', 'Ash'])
But when I pass the function an argument, it returns:
File "<input>", line 8
else "i".islower() == True:
^
SyntaxError: invalid syntax
What am I doing wrong? Any help greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire