Exercise 46

Write a Python algorithm as a function which takes as parameter a string variable s and which returns the list of all uppercase characters found in s.


def listShift (s):
# initialization of the list of capital letters
l_maj = []

for x in s:
if x.isupper ():
l_maj.append (x)
return l_maj

# Example:
s = "Tkinter is the most popular GUI Pytnon Framework"
print (listShift(s)) # output: ['T', 'G', 'U', 'I', 'P', 'F']
Younes Derfoufi

Leave a Reply