v Chain Together Lists - Python

Chain Together Lists

Preliminaries

from itertools import chain

Create Two Lists

# Create a list of allies
allies = ['Spain', 'Germany', 'Namibia', 'Austria']

# Create a list of enemies
enemies = ['Mexico', 'United Kingdom', 'France']

Iterate Over Both Lists As A Single Sequence

# For each country in allies and enemies
for country in chain(allies, enemies):
    # print the country
    print(country)
Spain
Germany
Namibia
Austria
Mexico
United Kingdom
France