Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implementation of Reverse String using Recursion in Python

NotificationsYou must be signed in to change notification settings

arnab132/Reverse-String-using-Recursion-in-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

This is a Python Program to reverse a string using Recursion.

Problem Description:

The program takes a String and reverses the string using Recursion.

Problem Solution:

  1. Take a string from the user.
  2. Pass the string as an argument to a recursive function to reverse the string.
  3. In the function, put the base condition that if the length of the string is equal to 0, the string is returned.
  4. Otherwise recursively call the reverse function to slice the part of the string except the first character and concatenate the first character to the end of the sliced string.
  5. Print the reversed string.
  6. Exit.

Program Explanation:

  1. User must enter a String.
  2. The string is passed as an argument to a recursive function to reverse the string.
  3. In the function, the base condition is that if the length of the string is equal to 0, the string is returned.
  4. If not equal to 0, the reverse function is recursively called to slice the part of the string except the first character and concatenate the first character to the end of the sliced string.
  5. The reversed string is printed.

Runtime Test Cases:

Case 1:Enter the string to be reversed: hello worlddlrow olleh

Case 2:Enter the string to be reversed: firsttsrif

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp