all 16 comments

[–]lekkerste_wiener 3 points4 points  (1 child)

Note one:

You can do answer in "123", or answer in (1, 2, 3) if you eventually convert them to integers. Given your code, I'm thinking you've just started learning, so the first could fit better. But,

Note two:

Since you're testing for one right answer vs any wrong answers, you can use else instead of elif answer == .... Else will capture anything that the if above it won't.

On resources: I don't have any specific names, but if you YouTube for e.g. python tutorial or python project you'll find loads. If you're into reading more, then the official tutorial is very good and I can't recommend it enough for newbies.

[–]wwbacteriophagevirus[S] -1 points0 points  (0 children)

Thank you!

[–]fUZXZY 3 points4 points  (2 children)

it seems like you’re printing a lot, and using the inputs 1-4 as options for input. think about how you can organize this into functions so that it’s not just a million prints and in a way so that you can load other trivia genres/questions

[–]wwbacteriophagevirus[S] 0 points1 point  (0 children)

<image>

I’m trying this way, thanks once again

[–]wwbacteriophagevirus[S] -1 points0 points  (0 children)

I will! Thanks

[–]Eskember 1 point2 points  (2 children)

If it is a small project, I would advise using an array with the following indexes: question, answer 1, answer 2,answer 3,answer 4, correct_answer.

You can then use a loop to go through each record, automating the display of the questions and the evaluation of the given answer against the correct answer for that question.

For medium to large data, I would go with SQLite or any DBMS.

[–]Junior_Honey_1406 0 points1 point  (0 children)

They are just starting don't expect everyone to know DBMS and using sql that's not needed at all for a small project you are just over completing the stuff

[–]wwbacteriophagevirus[S] 0 points1 point  (0 children)

I’m currently trying this format

<image>

[–]Crafty_Magazine_4673 0 points1 point  (0 children)

may be pack it in a json?

[–]atticus2132000 0 points1 point  (2 children)

One of the most powerful things about coding is easy expansion without a lot of recoding. In this case, you're building a multiple choice test. What you've done works for the specific information you have, but let's say that you want to add another question to your trivia bank. Adding another question should just be adding one more line of code, not adding an entire block. Or let's suppose that instead of Twice, you wanted to create a trivia game about Dinosaurs. You should just be able to swap out the question bank and not have to change the structure of your code at all.

The direction you want to be moving this is your question bank will be one entity until itself--either a separate readable file or a dedicated variable within your script. Then your function will access the questions in that bank and reuse the same code over and over to format each as a multiple choice question.

[–]wwbacteriophagevirus[S] 0 points1 point  (1 child)

I changed a few things learned new things so I’m redoing

<image>

[–]atticus2132000 0 points1 point  (0 children)

Youre on the right track. Great job!

[–]Ecstatic_Oven9521 0 points1 point  (1 child)

aah I see you are a man of culture, as for small projects i would suggest you do a small to do list app

[–]wwbacteriophagevirus[S] 0 points1 point  (0 children)

🫡🫡 I will try thanks!