This is my function. I want it to return all of the uppercase characters in the string (x) and if there are no upper case letters, then just return ' '.
def upper(x):
for c in x:
if c.isupper():
return(c)
elif x.islower():
return('')
I'm looking for it to give me something like this when I run it:
upper("aBBa")
'BB'
upper("abba")
''
However, it's only giving me the first uppercase letter of the string, instead of all of the uppercase letters. I thought using the 'for' loop would resolve this, but apparently not.
upper("aBBa")
'B'
upper("ABC")
'A'
Any suggestions are appreciated.