Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to extract only the first sentence from the dictionary?

I’m trying to create a game in python called "Save the girl"
One man will kidnap a girl and will keep him in his place and ask money from her family.

To reach his place he will ask three questions. First he will ask one question and if they answer it then he will give a clue to reach his place.

For this I’m storing all the questions and answer in a form of dictionary

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Eg:

Quiz_dict={"What did the Romans call Scotland?":"Japan","Which company makes the Galaxy 
              series of smartphones?":"Samsung"}

Now I just want the first question from the dictionary. How to do that??

I gave the command like

keys = "".join(list(Quiz_dict.keys()))
    print(keys[0])

But the output was the first letter of the first question (ie.W).
Please help me out

>Solution :

list(Quiz_dict)[0] 

should serve the purpose

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading