str='plus2net'
str_rev=''.join(reversed(str))
print(str_rev)
Output
ten2sulp
str='plus2net'
n=len(str) # length of the string
for i in range(n-1,-1,-1):
print(str[i],end='')
Output
ten2sulp
str='plus2net'
print(str[:2]) # first two chars from left # pl
print(str[:-2]) # except last two chars # plus2n
print(str[-1]) # last position # t
print(str[::]) # full string starting from left # plus2net
print(str[::-1]) # from last position full string # ten2sulp
str='plus2net'
x=''
for i in str:
x=i+x
print(x)
Output ( we are adding incremental char to left of the string x )
ten2sulp
All String methods String Palindrome checking
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.