I am creating a quiz in the EU. I got to:
import random as r import timeit as tr import time as t print "How many questions would you like?" q = int(raw_input()) count = 0 while q > count: aus_country = r.randrange(1,29) from random import choice if aus_country == 28: country = "Austria" country_1 = ['Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Ireland', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Spain', 'Sweden', 'United Kingdom'] country = choice(country_1) print "What is the capital of", country ans = raw_input() """I would not like to have 28 if statements here like: count = count + 1
However, I would like to know if there is a better way to check the capital, then there are 28 such statements as:
if ans == London and country == United_Kindom: print "Correct" if ans == Vienna and country == austria: print "Correct ... else: print "Wrong"
source share