If you want to only those values have the first uppercase letter.
friends = ["Mohamed", "Shady", "ahmed", "eman", "Sherif"]
for a in friends:
if a[0].isupper():
print(a)
Output
Mohamed
Shady
Sherif
You can try this too
friends = ["Mohamed", "Shady", "ahmed", "eman", "Sherif"]
uppercase = list(filter(lambda e: e[0].istitle(),friends) )
lowercase = list(filter(lambda e: e[0].islower(),friends))
print(uppercase)
print(lowercase)
OUTPUT
['Mohamed', 'Shady', 'Sherif']
['ahmed', 'eman']
If you want only the titleCase "(use for a name.)" string You can use str.istitle()
.
friends = ["Mohamed", "Shady", "ahmed", "eman", "Sherif"]
for a in friends:
if a.istitle():
print(a)
OUtput
Mohamed
Shady
Sherif