![Python-courses-python-exercises](https://1.bp.blogspot.com/-T3BongcoJFo/X4CftQxVL8I/AAAAAAAAB5U/Lf59WgNyhGo2FdogKqxv0PIy_Ef7XDPdgCLcBGAsYHQ/s0/my-python-courses-python-exercises-with-solutions.png)
Exercise 92
Write a python program as a function which takes a string s as parameter and returns True if the string s contains at least one uppercase character and False otherwise.
Solution
def containsUpper(s):
# define and initialize a variable which counts the number of capitals
counter = 0
# browse the characters in the string s
for x in s:
# increment the counter each time the character encountered is in uppercase
if x.isupper ():
counter = counter + 1
if counter> 0:
return True
else:
return False
# Example
print (containsUpper ("djangoFramework")) # prints True
print (containsUpper ("djangoframework")) # prints false
Younes Derfoufi
my-courses.net
my-courses.net