About 124,000 results
Open links in new tab
  1. How do I reverse a string in Python? - Stack Overflow

    May 31, 2009 · One rationale for excluding a string.reverse() method is to give python ... reverse_a_string(a) print(rev) ...

  2. python - How to continuously print input strings in reverse, but …

    Mar 5, 2022 · Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Done", "done", or "d" for the line …

  3. Best way to loop over a python string backwards - Stack Overflow

    Aug 9, 2015 · What is the best way to loop over a python string backwards? The following seems a little awkward for all the need of -1 offset: string = "trick or treat" for i in range(len(string)-1, 0 …

  4. python - Understanding string reversal via slicing - Stack Overflow

    The "-1" part represents the "step" part of the slicing—in this case, it goes through the string 1 character at a time, but backwards (a negative step means start from the end of the string). If …

  5. python - How do I reverse a list or loop over it backwards? - Stack ...

    Oct 15, 2010 · I find (contrary to some other suggestions) that l.reverse() is by far the fastest way to reverse a long list in Python 3 and 2. I'd be interested to know if others can replicate these …

  6. Python reversing a string using recursion - Stack Overflow

    I want to use recursion to reverse a string in python so it displays the characters backwards (i.e "Hello" will become "olleh"/"o l l e h". I wrote one that does it

  7. How to reverse user input in Python - Stack Overflow

    Mar 17, 2015 · I am working on a script that takes the user input and reverses the whole input. for example if the user inputs "London" it will be printed as "nodnol" . I am currently being able to …

  8. Reversing a String in Python Recursively - Stack Overflow

    Sep 23, 2013 · For a homework assignment I have to create a recursive function that reverses a string. Here's what I have currently. The last three lines of code were made by the instructor …

  9. Reversing a string in Python using a loop? - Stack Overflow

    Dec 25, 2016 · Are you trying to reverse the string or print the characters in reverse order? Your title implies the former but your code seems to be trying to do the latter. If you want to reverse …

  10. Reverse Indexing in Python? - Stack Overflow

    My direct answer is just a[::-1]. The following part is some possible complications people may find if they are using different version of python. Sorry about the confusion. I am new here, do you …

Refresh