044 Palindrome, Reversing String in Python - Comprehensive Python In Tamil
REPL
❯ uv run python
Python 3.14.3 (main, Feb 3 2026, 15:32:20) [Clang 17.0.0 (clang-1700.6.3.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> numbers = [1, 2, 3]
>>> numbers.reversed()
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
numbers.reversed()
^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'reversed'. Did you mean: 'reverse'?
>>> numbers.reverse()
>>> numbers
[3, 2, 1]
>>> string = "Hello Ha!"
>>> string.reverse()
Traceback (most recent call last):
File "<python-input-5>", line 1, in <module>
string.reverse()
^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'reverse'
>>> string[::-1]
'!aH olleH'
>>> "hello"
'hello'
>>> "hello"[::-1]
'olleh'
>>> "hello" == "hello"[::-1]
False
>>> language = "malayalam"
>>> language == language[::-1]
True
>>> "malayalam"[::-1]
'malayalam'
>>> "malayalam ".strip
<built-in method strip of str object at 0x107e11270>
>>> "malayalam ".strip()
'malayalam'
>>> "malaylam "[::-1]
' malyalam'
>>> "malayalam " == "malaylam "[::-1]
False
>>> "malayalam ".strip() == "malaylam ".strip()[::-1]
False
>>> stripped_string = "malayalam ".strip()
>>> stripped_string
'malayalam'
>>> stripped_string == stripped_string[::-1]
True
>>> "malayalam ".strip() == ("malaylam ".strip())[::-1]
False
>>> ("malaylam ".strip())
'malaylam'
>>>Code