Python List | extend method
Start your free 7-days trial now!
list.extend(~) method adds all items of an iterable to the end of a list.
The iterable to be added to the end of the list.
To add all items of list
winter_sports to the end of list
sports = ['Basketball', 'Football', 'Tennis']winter_sports = ['Skiing', 'Snowboarding']sports.extend(winter_sports)print(sports)['Basketball', 'Football', 'Tennis', 'Skiing', 'Snowboarding']
Note that even after the above, the
winter_sports list remains intact: