Simply exclude the end range index…
>>> foo[3::-1]
'3210'
Ironically, about the only option I think you didn’t try.
More Related Contents:
- Understanding string reversal via slicing
- Why python’s list slicing doesn’t produce index out of bound error? [duplicate]
- How to explain the reverse of a sequence by slice notation a[::-1]
- How can I slice each element of a numpy array of strings?
- What does += mean in this context?
- How to convert a string in the desired manner?
- Format timedelta to string
- How to search and replace text in a file?
- How to get a string after a specific substring?
- Convert JSON string to dict using Python
- Print string to text file
- How can I do multiple substitutions using regex?
- How to find char in string and get all the indexes?
- Extract email sub-strings from large document
- Math operations from string [duplicate]
- Find index of last occurrence of a substring in a string
- Safely evaluate simple string equation
- Strip spaces/tabs/newlines – python
- How to generate random strings in Python?
- How to convert a string list into an integer in python [duplicate]
- Convert list of strings to dictionary
- How do I check if raw input is integer in python 2.7?
- Sort list of strings by a part of the string
- Is there a way to split a string by every nth separator in Python?
- Python Remove Comma In Dollar Amount
- How do I escape curly-brace ({}) characters in a string while using .format (or an f-string)?
- How to replace whitespaces with underscore?
- How do I verify that a string only contains letters, numbers, underscores and dashes? [duplicate]
- Fast string array – Cython
- Python replace function [replace once]