- reverse() and reversed() both are python in-buid function which are used to reverse the content of the list.
- reverse() is only applicable on list.
- while reversed() is also work on the string data type.
Syntax-
list.reverse()
reversed(list)
program-
l=[1,2,3]
print("List is",l)
l.reverse()
print("Reverse list is",l)
print("Again reverse by reversed() function",*reversed(l))
s="Mytext"
print("string is",s)
print("String in reverse order",*reversed(s))
List is [1, 2, 3]
Reverse list is [3, 2, 1]
Again reverse by reversed() function 1 2 3
string is Mytext
String in reverse order t x e t y M