![Python-courses-python-exercises](https://1.bp.blogspot.com/-T3BongcoJFo/X4CftQxVL8I/AAAAAAAAB5U/Lf59WgNyhGo2FdogKqxv0PIy_Ef7XDPdgCLcBGAsYHQ/s0/my-python-courses-python-exercises-with-solutions.png)
Exercise 61
Resume the previous exercise (Exercise60) without using the reverse() method in python.
Solution
def reverseList (L):
# initialization of the inverted list
lReverse = []
# iterate over the elements of the list L and insert them in an inverted way
for item in L:
lReverse.insert (0, item)
return lReverse
# Example
L = ['Java', 'Python', 'PHP', 'C ++']
print (reverseList (L)) # the output is: ['C ++', 'PHP', 'Python', 'Java']
Younes Derfoufi
my-courses.net
my-courses.net