Recents in Beach
Home
Notes
_BCA
__DHTML
__DBMS - I
__ADVANCED C
__FOS
__OOPS
__CO
__DS
__SM
__JAVA
__SAQAT
__E-COMMERCE
__DBMS - II
__CN
__ASP.NET
__PYTHON
__IS
G. U. OLD PAPER
_BCA
G. U. UPDATE
_Old Paper
_Syllabus
_Result
G.U. SYLLABUS
_BCA
Interchange First Last Element
def swap (ls1):
if len(ls1) >= 2:
ls1[0],ls1[-1]=ls1[-1],ls1[0]
return ls1
my_list=[1,2,3,4,5]
print("Before swap :",my_list)
swap_list=swap(my_list)
print("After swap :",swap_list)
Output:-
Before swap : [1, 2, 3, 4, 5]
After swap : [5, 2, 3, 4, 1]
Post a Comment
0 Comments
Contact Form
Name
Email
*
Message
*
Social Plugin
Followers
Popular Posts
QUIZ EXAMINATION
August 28, 2023
PRACTICAL EXAM
October 09, 2023
Python Practicals
July 26, 2023
Ads
Powered by Blogger
0 Comments