Exercise 27

Write a Python algorithm that determines the list of words starting with a capital letter in a given text T.


def beginMaj (T):
# initialization of the list of words that start with a capital letter
uppercase = []
# convert the text T to a list:
L = T.split ()
for word in L:
if (word [0].isupper()):
uppercase.append (word)
return uppercase
# Example
T = "Python is more power thant Java"
print (beginMaj(T)) # the output is: ['Python', 'Java']
Younes Derfoufi

Leave a Reply