Q. Write a program that reverses a list of integers (in place).

Answer :-

lst = eval(input("Enter a list :- "))
lst.reverse()
print(lst)

Output :- 

Enter a list :- [ 1,2,3,4,5,6,7,8,9]
[9, 8, 7, 6, 5, 4, 3, 2, 1]
>>>

Enter a list :- [ "Express" , "Portal" , "Walla" , "Path" ]
['Path', 'Walla', 'Portal', 'Express']
>>>


8 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. your site is very thankfull for finding appropirate solution

    ReplyDelete
  2. BEAST SITE SIR! THANKS FOR THE HELP!

    ReplyDelete
  3. Sir can u do without using functions

    ReplyDelete
    Replies
    1. Yes, simply write
      print( lst [ -1 :-len(lst) -1:-1])

      Delete
  4. thank you so much

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post