Computer Science
Input the string 'My School'. Write a script to partition the string at the occurrence of letter 'h'.
Python
Python String Manipulation
2 Likes
Answer
s = "My School"
print(s.partition('h'))Output
('My Sc', 'h', 'ool')
Answered By
1 Like
Related Questions
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 "*".
What will be the output of the following code?
Text = "Mind@Work!" ln = len(Text) nText = "" for i in range(0, ln): if Text[i].isupper(): nText = nText + Text[i].lower() elif Text[i].isalpha(): nText = nText + Text[i].upper() else: nText = nText + 'A' print(nText)Write a program to convert a string with more than one word into titlecase string where string is passed as parameter. (Titlecase means that the first letter of each word is capitalized.)
Write a program that takes a sentence as an input parameter where each word in the sentence is separated by a space. The function should replace each blank with a hyphen and then return the modified sentence.