Home › Interview Questions › How do you reverse a string in Python using slicin…

How do you reverse a string in Python using slicing and using a for loop?

🟢 Easy Conceptual Fresher level
2Times asked
Oct 2026Last seen
Oct 2026First seen

💡 Model Answer

Using slicing: s[::-1] returns a new string that is the reverse of s. It works by stepping through the string backwards. Using a for loop: iterate over each character in s and prepend it to a new string: reversed_str = '' ; for char in s: reversed_str = char + reversed_str. Both methods produce the same result. The slicing method is more concise and typically faster, while the loop method demonstrates manual string construction. Both run in O(n) time and O(n) space.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500