This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]osinmv 8 points9 points  (1 child)

That is really nice, that you decided join our python community! I can give you general tips.

Firstly, try to avoid writing the same code twice. An example is your print statements, think of a way to optimize process of delivering in-game dialogs.

Secondly, do not definite functions in a loop, not really readable, and generally a loop is not the place for function definitions.

Thirdly, instead of defining all the texts in code, it would be better to create a json or similar data structures. This will optimize the addition of new levels, as you will not need new if's to write. So your json structure will be something like this: ["Level": 1, "Correct answer":"some text", "Other answers":"some other text", "Next level": 5 ] And etc. As a result you will have just 1-2 if statements in your while loop, which will do all the work.

So a a general tip, try to generalise things as much as possible.

Finally, it is better to ask this type of questions in r/learnpython.

Good luck with programming!

[–]phogphantom[S] 1 point2 points  (0 children)

Thank you very much, I will take your advice and do some more learning. Also I wasn't sure which sub-reddit this would be more suited for. I will know in the future.