Perluas daftar Pyton

animals = ['dog', 'cat']

# tuple
mammals = ('tiger', 'elephant')

animals.extend(mammals)

print('Updated list:', animals)

# dictionary
birds = {'owl': 1, 'parrot': 2}

animals.extend(birds)

print('Updated list:', animals)

#Updated list: ['dog', 'cat', 'tiger', 'elephant']
#Updated list: ['dog', 'cat', 'tiger', 'elephant', 'owl', 'parrot']
David Cao