In Python, string object is considered as a sequence of characters represented by double quotes (“”) or single quotes (”).

To see how to reverse the string in PowerShell, have a look at

Accessing characters through array index

s = ""

#To get the first character
print("First Character: ", s[0])

#To get the last character
print("Last Character: ", s[-1])


Display full string

s = ""

#To display full string
print("String is: ", s)

#Iterating through all indexes
print("String is: ", s[0:len(s):1])

#In short form
print("String is: ", s[::1])

#Skipping alternate characters
print("Skipping alternate characters in String: ", s[::2])


Reversing the String

Reverse string by iterating through array

s = ""

#Iterating all indexes - 
print("Reversed string:", s[-1:-len(s)-1:-1])

#In Short
print("Reversed string:", s[::-1])


Reverse string using for loop

s = ""

strn = ""
for i in s:
  strn = i + strn
print("Reversed String:", strn)


Reverse string using reversed method

s = ""
print("Reversed string:", ''.join(reversed(s)))


If you know of other ways to reverse the string in Python, comment below with the code !!!

Thank you for reading the article.