mercredi 25 mars 2015

Choosing a random item from one of two lists, based on a random item from a third

I am trying to select a random city of a random country, using the following code:



COUNTRIES= ["NL", "NO"]

NL = [
"Assen", "Almere", "Leeuwarden", "Nijmegen", "Groningen",
"Maastricht", "Eindhoven", "Amsterdam", "Enschede", "Utrecht",
"Middelburg", "Rotterdam"
]

NO = [
"Fredrikstad", "Baerum", "Oslo", "Ringsaker", "Gjovik",
"Drammen", "Sandefjord", "Skien", "Arendal", "Kristiansand",
"Stavanger", "Bergen", "Forde", "Alesund", "Trondheim",
"Stjordal", "Bodo", "Tromso", "Alta"
]

CHOSEN_CITY = random.choice(random.choice(COUNTRIES))

print CHOSEN_CITY


However, this only ever gives me one of 'L', 'O' or N. What am I doing wrong here?





Aucun commentaire:

Enregistrer un commentaire