Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to reverse string using append and reverse() in python?

Description

To reverse a given string in python3.

Process
Append()

  Append is to join or add on to the end of something.

  The append() method takes a single item and adds it to the end of the list.

Reverse()

  It reverse the element in a list.

Sample Code

#get input from user
n=input(“Enter the string:”)

#declare an empty list
l=[]

#take input string in a loop
for i in n:

#append to the empty list
l.append(i)

#make reverse the list
l.reverse()

#join the ” in the list
a=”.join(l)
print(“The reversed version of string is\n”,a)

Screenshots
reverse string using append and reverse() in python