Hello, i were trying to learn python and i decided it would be a great idea using the OpenTDB database, i said “Why not” so…
I did it, and the code is available for download on the next link:
It’s a simple trivia game using python shell, that lets you play X number of questions, so you can play trivia alone. It counts correct answers 0, incorrect answers, max combo and the last combo you got.
I need to give a remainder that I’m not a native English Speaker, so if you find any typos, wrong words, or orthographic errors, I’ll accept any commit gets sent about that matter, but for adding new functionalities or editing the code syntax, I’ll need to check it.
Very nice! Not a bad first project. I created a pull request on Github you can see I made some spelling corrections and moved your functions to a better place, I didn’t want to do everything though, you can see line for line what I changed here.
I’d suggest improving the output as it can be hard to read. A nice way to do that is applying ANSI colours with escape sequences like this;
PURPLE = '\033[95m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
print(colour.GREEN + "Hello")
I would also recommend making a function for the output, and also you can clear the screen with(for Windows+Linux);
os.system('cls' if os.name == 'nt' else 'clear')
You want your functions to also be above the rest of your code, under your imports instead of inside the while loop, It makes it easier to read your main loop by putting your functions together.
It’s a good start! If you work on making a single function handle all the text output the main loop will be so much cleaner, and you’ll have a single function handling how it’s displayed.
Or you could try tkinter or PyQT and create a GUI