I'm trying to write a code where I should have a few questions and an input for an answer. If the answer is correct, then it will tell me correct and wrong if it is wrong. I found a similar solution on this site, but the difference is that I need to use a dictionary. Heres a rough example of what is expected:

What is the French word for ‘one’? un

That is correct. You have 1 right and 0 wrong.

What is the French word for ‘two’? deux

That is correct. You have 2 right and 0 wrong.

What is the French word for ‘three’? trios

That is incorrect. The correct word is trois.

You have 2 right and one wrong.

I was assigned a random partner to work on this with, but he never did anything for it and I'm stuck doing it by myself. Help please?

Edit: if you come up with code for this, simple is better. We haven't studied that much stuff in class yet.

Recommended Answers

All 2 Replies

Start simple: write the code which indefinitely asks the user the French word for 'one' and always answers that is correct.

Here is something for you to start with

questions = [
                   ["What is the French word for one?", "un" ],
                   ["What is the French word for two?", "deux"],
                         ...
            ]
right = 0
wrong = 0
for question in questions:
    ans = raw_input(question[0])
    if ans.strip() == question[1]:
        ...
    else:
        ...
    print ...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.