Assuming a
is a string. The Slice notation in python has the syntax –
list[<start>:<stop>:<step>]
So, when you do a[::-1]
, it starts from the end towards the first taking each element. So it reverses a. This is applicable for lists/tuples as well.
Example –
>>> a = '1234' >>> a[::-1] '4321'
Then you convert it to int and then back to string (Though not sure why you do that) , that just gives you back the string.
Related Posts:
- WinError 2 The system cannot find the file specified (Python)
- Could not find a version that satisfies the requirement tensorflow
- Could not find a version that satisfies the requirement tensorflow
- Local variable referenced before assignment?
- TypeError: write() argument must be str, not bytes (Python 3 vs Python 2 )
- Change figure size and figure format in matplotlib
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- Type error Unhashable type:set
- TypeError: ‘_io.TextIOWrapper’ object is not subscriptable
- dump() missing 1 required positional argument: ‘fp’ in python json
- Does python have header files like C/C++?
- SyntaxError: unexpected EOF while parsing
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- How to install pip with Python 3?
- Import Error: No module named numpy
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- Relative imports in Python 3
- Pip freeze vs. pip list
- Best way to convert string to bytes in Python 3?
- TypeError: not all arguments converted during string formatting python
- RuntimeWarning: invalid value encountered in divide
- Using Python 3 in virtualenv
- hashlib.md5() TypeError: Unicode-objects must be encoded before hashing
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- AttributeError: ‘module’ object has no attribute ‘urlopen’
- Can’t fix “zipimport.ZipImportError: can’t decompress data; zlib not available” when I type in “python3.6 get-pip.py”
- Python Traceback (most recent call last)
- Unable to plot Double Bar, Bar plot using pyplot for ndarray
- How to pip or easy_install tkinter on Windows
- ‘method’ object is not subscriptable. Don’t know what’s wrong
- error UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte
- Error: ” ‘dict’ object has no attribute ‘iteritems’ “
- What is the meaning of [:] in python [duplicate]
- How to upgrade pip3?
- TypeError: Missing 1 required positional argument: ‘self’
- What is __pycache__?
- SystemError: Parent module ” not loaded, cannot perform relative import
- TypeError: ‘<=' not supported between instances of 'str' and 'int' [duplicate]
- Remove list from list in Python
- TypeError: unsupported operand type(s) for -: ‘str’ and ‘int’
- How to Read .txt in Pandas
- TypeError: can’t use a string pattern on a bytes-like object in re.findall()
- Pinging servers in Python
- Add Legend to Seaborn point plot
- How to pass arguments to a Button command in Tkinter?
- How to remove specific substrings from a set of strings in Python?
- How do I install the yaml package for Python?
- Type error: cannot convert the series to
- error: Failed to load the native TensorFlow runtime
- ImportError: No module named ‘encodings’
- How to remove punctuation marks from a string in Python 3.x using .translate()?
- Subplot for seaborn boxplot
- enumerate() for dictionary in python
- Why Python 3.6.1 throws AttributeError: module ‘enum’ has no attribute ‘IntFlag’?
- Create 3D array using Python
- How to use sys.exit() in Python
- installing urllib in Python3.6
- What is sys.maxint in Python 3?
- How can I install Python’s pip3 on my Mac?
- What is the meaning of ‘for _ in range()
- Difference between scikit-learn and sklearn
- Python sockets error TypeError: a bytes-like object is required, not ‘str’ with send function
- Pipenv: Command Not Found
- Python: AttributeError: ‘_io.TextIOWrapper’ object has no attribute ‘split’
- How to detect key presses?
- Youtube_dl : ERROR : YouTube said: Unable to extract video data
- Anaconda Installed but Cannot Launch Navigator
- ImportError: No module named ‘yaml’
- How to print multiple lines of text with Python
- ImportError: No module named ‘cv2’ Python3
- Python 101: Can’t open file: No such file or directory
- Split a python list into other “sublists” i.e smaller lists
- TypeError: argument of type ‘NoneType’ is not iterable
- How do I run pip on python for windows?
- How to fix ‘RuntimeWarning: divide by zero encountered in double_scalars’
- What does {0} mean in this Python string?
- Tab Error in Python
- Installation of pygame with Anaconda
- Using unicode character u201c
- Python 3.5.1 urllib has no attribute request
- matplotlib: plot multiple columns of pandas data frame on the bar chart
- built-in range or numpy.arange: which is more efficient?
- How can I copy a Python string?
- Why do I get this error “TypeError: ‘method’ object is not iterable”?
- How to completely uninstall python 2.7.13 on Ubuntu 16.04
- Spell Checker for Python
- “Python version 2.7 required, which was not found in the registry” error when attempting to install netCDF4 on Windows 8
- Getting a name error when trying to input a string [duplicate]
- How to install NumPy for Python 3.6
- In python, how can I print lines that do NOT contain a certain string, rather than print lines which DO contain a certain string:
- input() error – NameError: name ‘…’ is not defined
- Error loading MySQLdb module: No module named ‘MySQLdb’
- How do you switch between python 2 and 3, and vice versa?
- Iterating over dictionary items(), values(), keys() in Python 3
- Homebrew brew doctor warning about /Library/Frameworks/Python.framework, even with brew’s Python installed
- Undefined variable error in function
- Python 3 integer division [duplicate]
- Python – difference between two strings