Function in Python that Reverse a given List

 The following function in python will return the reverse of the given list.


    

   def reverseList(n):
    reverseL = uList[:]
    for i in range(len(reverseL)//2):
        reverseL[i], reverseL[len(reverseL)-i-1] = reverseL[len(reverseL)-i-1], reverseL[i] 
    print(f"The reverse of the original list {uList} is {reverseL}")
    
uList = [45,66,7,1,333]

reverseList(uList)

    

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes