Answer to Question #255529 in Python for GANESH

Question #255529

How to reverse a string in a given sentence. a. Example: Given string is “ Ram is learning in CCBP Intensive course”. Reverse the word “learning” in the above sentence


1
Expert's answer
2021-10-23T08:05:37-0400
def reverse(s):
    if len(s) == 0:
        return s
    else:
        return reverse(s[1:]) + s[0]
string =("Ram is learning in CCBP Intensive course").split(" ") 
print("The reverse of learning is: "+reverse(string[2]))
string[2] = reverse(string[2])
str1 = " "
for i in string:
    str1 += i +" "
print(str1)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS