Q. Consider the string str1 = "Global Warming".
Write statements in Python to implement the following:
(a) To display the last four characters.
(b) To replace all the occurrences of letter 'a' in the string with "*".
Answer :-
a =
s = "Global Warming" print( s[-4 : ] )
Output :-
ming
>>>
b =
s = "Global Warming" new = "" for i in s : if i == "a" : new += "*" else : new += i print(new)
Output :-
Glob*l W*rming
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )