Answers for "given a string write a function that returns the string in reverse"

2

reverse string

def reverse_string(str):
  return str[::-1]
print(reverse_string("This string is reversed!"))
Posted by: Guest on July-09-2021
0

string reverse

// string::rbegin/rend
#include <iostream>
#include <string>

int main ()
{
  std::string str ("now step live...");
  for (std::string::reverse_iterator rit=str.rbegin(); rit!=str.rend(); ++rit)
    std::cout << *rit;
  return 0;
}
Posted by: Guest on November-02-2020

Code answers related to "given a string write a function that returns the string in reverse"

Python Answers by Framework

Browse Popular Code Answers by Language