Tuesday, November 19, 2019

append and extend methods in python


l1=[10,20,30]
l2=[40,50,60]
l1.extend(l2)
print(l1)
l1.extend('anil')
print(l1)
l1.append('anil')
print(l1)

output:
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60, 'a', 'n', 'i', 'l']
[10, 20, 30, 40, 50, 60, 'a', 'n', 'i', 'l', 'anil']

No comments:

Post a Comment

python class topic video