Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

extend list 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']
Source by www.howtouselinux.com #
 
PREVIOUS NEXT
Tagged: #extend #list #pyton
ADD COMMENT
Topic
Name
3+8 =