![Python-courses-python-exercises-python-certification](https://1.bp.blogspot.com/-T3BongcoJFo/X4CftQxVL8I/AAAAAAAAB5U/Lf59WgNyhGo2FdogKqxv0PIy_Ef7XDPdgCLcBGAsYHQ/s0/my-python-courses-python-exercises-with-solutions.png)
Exercise 47
Write a python program that determines the list of all the words which contains at least one uppercase character in a given text T. Example if T = "Python is a high level programming language. Originally developed by Guido van Rossum in 1989." The program returns the list:
['Python', 'Originally', 'Guido', 'Rossum']
Solution
# creating a function which test if given word contains at least one uppercase character
def testUpercase(s):
# initializing counter
counter = 0
for letter in s:
if letter.isupper():
counter = counter + 1
if counter > 0:
return True
else:
return False
T = "Python is a high level programming language. Originally developed by Guido van Rossum in 1989."
# initializing the list of all the words which contains at least one uppercase character
listUpper = []
# transform the text T to a list
L = T.split()
for word in L:
if(testUpercase(word)):
listUpper.append(word)
# display the list
print(listUpper)
# The output is : ['Python', 'Originally', 'Guido', 'Rossum']
Younes Derfoufi
my-courses.net
my-courses.net