Concatenation of two lists elements - list extend and copy methods

 #Concatenation of two lists elements

mylist1=[34,55,66,77,'krishna']

mylist2=[56,77,33,44]

mylist3=mylist1+mylist2

print(mylist3)

output:

[34, 55, 66, 77, 'krishna', 56, 77, 33, 44]

#using extend method

mylist1.extend(mylist2) # adding second list to first list

print(mylist1) 

outpput:

[34, 55, 66, 77, 'krishna', 56, 77, 33, 44]               

#copy one list to another list useing copy() method

mylist=[45,66,33,44,77]

newlist=mylist.copy() # copy list elemetns mylist to newlist

print(newlist)

output:
[45, 66, 33, 44, 77]






#python training, #python jobs in guntur, #python training in hyderabad

No comments:

Post a Comment

Latest Post

How to Generate Barcode and QR code For Our Products

 మీ products కి barcode / QR code generate చేయాలంటే OPTION 1: ONLINE (No Coding – Quick) Best for small shops / beginners 👉Free websites: T...