<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: capital quiz game in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/capital-quiz-game/m-p/1151155#M63980</link>
    <description>&lt;P&gt;So, are you challenging us or do you want help?&lt;/P&gt;&lt;P&gt;If you want help, what do you already have?&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2022 07:35:12 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-03-07T07:35:12Z</dc:date>
    <item>
      <title>capital quiz game</title>
      <link>https://community.esri.com/t5/python-questions/capital-quiz-game/m-p/1151132#M63978</link>
      <description>&lt;P&gt;&lt;BR /&gt;I&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 09:21:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/capital-quiz-game/m-p/1151132#M63978</guid>
      <dc:creator>Chelsea_Trusdell</dc:creator>
      <dc:date>2022-03-07T09:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: capital quiz game</title>
      <link>https://community.esri.com/t5/python-questions/capital-quiz-game/m-p/1151155#M63980</link>
      <description>&lt;P&gt;So, are you challenging us or do you want help?&lt;/P&gt;&lt;P&gt;If you want help, what do you already have?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 07:35:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/capital-quiz-game/m-p/1151155#M63980</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-03-07T07:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: capital quiz game</title>
      <link>https://community.esri.com/t5/python-questions/capital-quiz-game/m-p/1151175#M63981</link>
      <description>&lt;P&gt;I need help in the loop section. thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 09:14:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/capital-quiz-game/m-p/1151175#M63981</guid>
      <dc:creator>Chelsea_Trusdell</dc:creator>
      <dc:date>2022-03-07T09:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: capital quiz game</title>
      <link>https://community.esri.com/t5/python-questions/capital-quiz-game/m-p/1151184#M63982</link>
      <description>&lt;LI-CODE lang="python"&gt;import random

capitals = {
    "Austria": "Vienna",
    "Belgium": "Brussels",
    "Bulgaria": "Sofia",
    "Croatia": "Zagreb",
    "Cyprus": "Nicosia",
    "Czech Republic": "Prague",
    "Denmark": "Copenhagen",
    "Estonia": "Tallin",
    "Finland": "Helsinki",
    "France": "Paris",
    "Germany": "Berlin",
    "Greece": "Athens",
    "Hungary": "Budapest",
    "Ireland": "Dublin",
    "Italy": "Rome",
    "Latvia": "Riga",
    "Lithuania": "Vilnius",
    "Luxembourg": "Luxembourg City",
    "Malta": "Valletta",
    "Netherlands": "Amsterdam",
    "Poland": "Warsaw",
    "Portugal": "Lisbon",
    "Romania": "Bucharest",
    "Slovakia": "Bratislava",
    "Slovenia": "Ljubljana",
    "Spain": "Madrid",
    "Sweden": "Stockholm",
}
exit_keywords = ["exit", "quit", "q"]



def quiz(state=None, continue_until_exit=False):
    if not state:
        state = random.sample(capitals.keys(), 1)[0]
    capital = capitals[state]

    answer = input("Input the capital of {} or type 'exit': ".format(state)).lower()

    if answer in exit_keywords:
        print("The right answer was {}. Thanks for playing!".format(capital))
        return

    answer_is_correct = answer == capital.lower()
    print("That's correct!" if answer_is_correct else "Wrong, try again!")

    if continue_until_exit or not answer_is_correct:
        state = None if answer_is_correct else state
        quiz(state, continue_until_exit)



print("Play until you get the correct answer\n")
quiz()

print("\n\nPlay until you quit manually\n")
quiz(continue_until_exit=True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Play until you get the correct answer

Input the capital of Sweden or type 'exit': Oslo
Wrong, try again!
Input the capital of Sweden or type 'exit': Stockholm
That's correct!


Play until you quit manually

Input the capital of Hungary or type 'exit': budapest
That's correct!
Input the capital of Slovenia or type 'exit': bratislava
Wrong, try again!
Input the capital of Slovenia or type 'exit': Ljubljana
That's correct!
Input the capital of Malta or type 'exit': VALLETTA
That's correct!
Input the capital of Czech Republic or type 'exit': prague
That's correct!
Input the capital of France or type 'exit': PaRiS
That's correct!
Input the capital of Latvia or type 'exit': q
The right answer was Riga. Thanks for playing!
&amp;gt;&amp;gt;&amp;gt; &lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 07 Mar 2022 09:52:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/capital-quiz-game/m-p/1151184#M63982</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-03-07T09:52:10Z</dc:date>
    </item>
  </channel>
</rss>

