Write a code snippet to convert a string to a list and reverse string in python
Below is the code to convert a string to a list in Python.
str1 = "developer india"
array=str1.split(" ")
print("The original string is: ",str1)
print("The reversed string is: ",array)
Here, we have reversed a string without using any in-built function.
print("Hello World")
str1 = "developer india "
str2 = ""
for i in str1: str2 = i + str2
print("The original string is: ",str1)
print("The reversed string is: ",str2)
Output:
The original string is: developer india
The reversed string is: aidni repoleved