How about:
>>> 'hello world'[::-1] 'dlrow olleh'
This is extended slice syntax. It works by doing [begin:end:step]
– by leaving begin and end off and specifying a step of -1, it reverses a string.
Related Posts:
- Convert bytes to a string
- Replacing instances of a character in a string
- Changing one character in a string
- Converting integer to string in Python
- How do I compare two strings in python?
- ValueError: could not convert string to float: id
- How do I lowercase a string in Python?
- How do I get a substring of a string in Python?
- Python- Robot Framework Rebot Using List
- How to update/upgrade a package using pip?
- Python vs Cpython
- How do I update\upgrade pip itself from inside my virtual environment?
- How to read a file line-by-line into a list?
- How can I represent an ‘Enum’ in Python?
- strip(char) on a string
- IndexError: too many indices for array
- numpy array: IndexError: too many indices for array
- How do I specify new lines on Python, when writing on files?
- Relative imports – ModuleNotFoundError: No module named x
- bash: pip: command not found
- Using global variables in a function
- How do I check what version of Python is running my script?
- How to convert list to string [duplicate]
- Python for-in loop preceded by a variable
- Python Linked List
- What does if __name__ == “__main__”: do?
- How to print without a newline or space
- Difference between del, remove, and pop on lists
- How can I install packages using pip according to the requirements.txt file from a local directory?
- Error: ‘int’ object is not subscriptable – Python
- How to measure elapsed time in Python?
- How to uninstall Anaconda completely from macOS
- Python: Start and stop timer [duplicate]
- Does Python have a ternary conditional operator?
- not all arguments converted during string formatting.. NO % variables
- How do I install opencv using pip?
- TypeError: ‘builtin_function_or_method’ object is not subscriptable
- Curve curvature in numpy
- Relative imports in Python 3
- ImportError: No module named sklearn.cross_validation
- ImportError: No module named sklearn.cross_validation
- How can I prevent the TypeError: list indices must be integers, not tuple when copying a python list to a numpy array?
- What are data classes and how are they different from common classes?
- “pip install unroll”: “python setup.py egg_info” failed with error code 1
- Tensorflow import error: No module named ‘tensorflow’
- Converting string into datetime
- ImportError: No module named matplotlib.pyplot
- working of \n in python [duplicate]
- ImportError: No module named matplotlib.pyplot
- How do I list all files of a directory?
- Print string to text file
- Accessing the index in ‘for’ loops?
- The difference between comparison to np.nan and isnull()
- How do I append one string to another in Python?
- How can I split and parse a string in Python?
- How to read a text file into a string variable and strip newlines?
- Python convert tuple to string
- write() versus writelines() and concatenated strings
- Why is it string.join(list) instead of list.join(string)?
- Why is it string.join(list) instead of list.join(string)?
- How to remove punctuation in python?
- Split string with multiple delimiters in Python [duplicate]
- How to check if the string is empty?
- How to check whether a str(variable) is empty or not?
- What does the ‘b’ character do in front of a string literal?
- How to add a string in a certain position?
- Remove all special characters, punctuation and spaces from string
- This can be done without regex:
- Pythonic way to create a long multi-line string
- ‘numpy.ndarray’ object has no attribute ‘index’
- Convert hex to binary
- Quoting backslashes in Python string literals
- Python string class like StringBuilder in C#?
- n-grams in python, four, five, six grams?
- Best way to replace multiple characters in a string?
- How do I remove a substring from the end of a string?
- Detect whether a Python string is a number or a letter
- Finding all possible permutations of a given string in python
- How do I append one string to another in Python?
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- Count the number of occurrences of a character in a string
- How can I find the first occurrence of a sub-string in a python string?
- How to join on multiple columns in Pyspark?
- Replacing a character from a certain index
- Pandas error “Can only use .str accessor with string values”
- urllib2.HTTPError: HTTP Error 403: Forbidden
- Convert a Unicode string to a string in Python (containing extra symbols)python string unicode type-conversion
- Create nice column output in python
- TypeError: decoding str is not supported
- AttributeError: ‘str’ object has no attribute ‘items’
- How to pad zeroes to a string?
- How does str(list) work?
- What is the difference between a string and a byte string?
- How to strip a specific word from a string?
- Python cant convert ‘list’ object to str error [closed]
- Using strip() to clean up a string
- Python code to remove HTML tags from a string
- Cannot concatenate ‘str’ and ‘float’ objects?
- How to repeat individual characters in strings in Python