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]
[9, 8, 7, 6, 5, 4, 3, 2, 1]
>>>
Enter a list :- [ "Express" , "Portal" , "Walla" , "Path" ]
['Path', 'Walla', 'Portal', 'Express']
>>>
your site is very thankfull for finding appropirate solution
ReplyDeleteThank you : )
DeleteBEAST SITE SIR! THANKS FOR THE HELP!
ReplyDeleteWelcome 😊😊
DeleteSir can u do without using functions
ReplyDeleteYes, simply write
Deleteprint( lst [ -1 :-len(lst) -1:-1])
thank you so much
ReplyDeleteWelcome 😊😊
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )