Jul-03-2022, 03:35 AM
(Jul-02-2022, 03:41 PM)SuperNinja3I3 Wrote: I want to reverse a list but want to store it in another list...
reverse the elements of the ‘myList’ and store that in ‘reversedList’
reversedList = mylist.reverse()Now, if it is homework and you have to right a function to do this yourself, my hints would be:
#1 Using a negative indexes you can start at the end of the list and move backwards. myList[-1] #the last item in the list myList[-2] #the second to last item... # 2 Python's len() function tells you how many items in the list and therefor how times it needs to loop and copy the item to a new list.