Reverse List Function in Python

#Pythoncoding 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻: 𝗪𝗿𝗶𝘁𝗲 𝗮 𝗣𝘆𝘁𝗵𝗼𝗻 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻 𝘁𝗼 𝗺𝗮𝗻𝘂𝗮𝗹𝗹𝘆 𝗿𝗲𝘃𝗲𝗿𝘀𝗲 𝗮 𝗴𝗶𝘃𝗲𝗻 𝗹𝗶𝘀𝘁 𝘄𝗶𝘁𝗵𝗼𝘂𝘁 𝘂𝘀𝗶𝗻𝗴 𝘁𝗵𝗲 𝗯𝘂𝗶𝗹𝘁-𝗶𝗻 𝗿𝗲𝘃𝗲𝗿𝘀𝗲() 𝗺𝗲𝘁𝗵𝗼𝗱 𝗼𝗿 𝘀𝗹𝗶𝗰𝗶𝗻𝗴 ([::-𝟭]). 𝗖𝗼𝗻𝘀𝘁𝗿𝗮𝗶𝗻𝘁𝘀: -Do not use reverse() or [::-1]. -The function should work for both numbers and strings. -The input list may contain duplicates and should maintain their order in reverse. -The function should return a new reversed list (not modify the original list). #Python #PythonDeveloper #Coding #100DaysOfCode #LearnPython #DataScience #MachineLearning

  • text

::-1 gives reverse string using extented slicing operation

Like
Reply

To view or add a comment, sign in

Explore content categories