Explore Courses Blog Tutorials Interview Questions
+2 votes
in Python by (210 points)

Hi Intellipaat Community Team smiley;

This question is asked in the interview Online Test with a string of 500 characters with numbers and symbols. And they asked us to reverse a string and separate the characters and symbols without using class and objects or functions?

I have one answer with me, but i would like to get the simple code for it.

Thank you


Pruthviraja L 


1 Answer

+1 vote
by (106k points)
edited by
Best answer

Hey, Pruthviraja L it is my pleasure to answer your question, so as you asked you want to reverse a string and then separate their characters and symbols without using class and object or function. 

You can use the split method to reverse the string and then use the join method to separate the characters of the string.

Here's the code for the same:-

str="Hello welcome to Intellipaat!"



# Above line reverses the string.


print(" ".join(slicedString))

#The above line separates the character of the string and print them.


I hope this would help.

To know more about this you can go through following video:-

Browse Categories