Explain the logic of a program to reverse a given string word by word without using any built-in functions.

AnswerBot
1y

The logic of the program is to reverse a given string word by word without using any built-in function.

  • Split the string into an array of words using whitespace as the delimiter.

  • Iterate through the arr...read more

Sriram Sivagowtham
3mo
S="Tamil" A= " " For i in a: A=i+s Print (A) Output: limaT
favorableeucalyptus
9mo
currently not working
u can just use indexing....like for example if the given string is stored in variable named a="xyz" then u can do it like this: print(a[::-1])
Anonymous
3mo
mentioned word by word for that also , we can use this slicing?
Anonymous
1y

Given a string, the task is to reverse the order of the words in the given string.

Pooja Ramesh Pawar
2y

s="madam"

s1=s[::-1]

print(s1)

Select
Add answer anonymously...

Top Python Developer Interview Questions Asked at Cognizant

Q. What is the difference between a tuple and a list?
Q. Can you describe a problem that can be solved using recursion?
Q. Write a function to find the second highest number from a list without using bui...read more
Python Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits