- Append: The append() method is used to add a single element to the end of a list in Python.It modifies the original list
- Reverse: The reverse() method reverses the elements of a list in place.It does not return any new list but modifies the original list.
- Append: append() takes a single argument and adds it to the end of the list.It doesn’t return any value; it modifies the list in-place.
- Reverse: The reverse() method reverses the order of elements in the list.It works only on lists, not strings or other iterables.
- print("Output for reverse a string using append and reverse keyword:")
def reverse_string(input_str):
char_list = []
for char in input_str:
char_list.append(char)
char_list.reverse()
reversed_str = ''.join(char_list)
return reversed_str
input_str = input("Enter the string: ")
reversed_str = reverse_string(input_str)
print("Reversed string :", reversed_str)