Exercise 45

Write a python program as a function which takes as parameters a character string s and which returns another string obtained from s by replacing all the characters in upper case by the diese char '#'


def removeUpper(s):
# create an empty string
s1 = ""
for x in s:
if x.isupper():
s1 = s1 + '#'
s1 = s1 + x
return s1
# testing algorithm
s = "Python Language is created by Guido Van Rossam"

# The output is : #ython #anguage is created by #uido #an #ossam

Younes Derfoufi

Leave a Reply