Skip to content
Advertisement

Python project basing on picture to guess the answer for the flag name , I think that the while loop is the problem

My code snippet:

JavaScript

I want to program a guessing game basing on the image of the flags from different countries. There are 6 countries which I picked. The user will have maximum 3 turns, if they are wrong 3 times, the game will end. The user cannot move to the next image until they guess correctly the current image right. I think the problem is the loop.

Advertisement

Answer

Your style of writing code is not that much right, if you are doing same things every time then you can turn that same things into a function and can call function is you need it and you are doing everything statically which is not a good practice. I have change most of the code you may not exactly understand but play with it and you will eventually understand it.

Explanation : Variable n is for level like things and b is to making sure program will not check 2 condition while checking answer. msg function is for success message and msgwrng function is for wrong answer. I have changed the variable name of Entry from entry to entrybox. I haven’t changed other things which should be changed but I think you will understand from here and change those code also.

Here’s your code. If you find anything wrong or didn’t understand anything ask in comment section.

If it helped you don’t forget to mark this as answer, it will help for future programmer also.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement