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

    There is no built in reverse method for Python's str object. How can I reverse a string?

  2. Python reversing a string using recursion - Stack Overflow

    Additionally, Python imposes a limit on stack size, and there's no tail call optimization, so a recursive solution would be limited to reversing strings of only about a thousand characters. …

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

    Python will "do the right thing" when filling in the start and stop so it iterates through the list backwards and gives you [10,9,8,7,6,5,4,3,2,1]. I've given the examples with lists, but strings …

  4. Best way to loop over a python string backwards

    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 …

  5. What is the most efficient way to reverse a string in Python?

    Jun 26, 2023 · If you look at Python's intermediate code (see Godbolt Compiler Explorer), you can also see that slicing is its own operation, so it's pretty much optimized as well. So, s[::-1] is the …

  6. 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 …

  7. python - Reverse a string without using reversed () or [::-1]? - Stack ...

    Sep 9, 2013 · 42 I came across a strange Codecademy exercise that required a function that would take a string as input and return it in reverse order. The only problem was you could not …

  8. How do I reverse words in a string with Python - Stack Overflow

    May 21, 2017 · That's not in-place; you're just reversing the order of the letters in each word. "In place" has a very specific meaning when it comes to data structures; it means you're …

  9. python - Reverse each word in a string - Stack Overflow

    May 27, 2017 · 0 A version without Python-level looping and with reversing the whole string once instead of each word separately.

  10. Reversing bits of Python integer - Stack Overflow

    Given a decimal integer (eg. 65), how does one reverse the underlying bits in Python? i.e.. the following operation: 65 → 01000001 → 10000010 → 130 It seems that this task can be broken …