DEV Community

wolding
wolding

Posted on

Lockdown projects - My first game using python

What you need to know:

I started self-teaching python in lockdown and this is one of my first completed projects. Also I am a big fan of the NFL which was the influence behind the rather niche category

The Game:

Screenshot of the game in action

A name-matching game, where the user is given the last name and 3 first names (1 correct) of a current Cincinnati Bengals player.

The code:


I used web-scraping to get the player names and stored them in a Class along with position to provide a clue, as some players have the same last name.

The user specifies the number of questions(x) and the questions are the first x items on a list of last names.

The correct answer first name is added to a list, then using random.sample(), 2 more are added.

This choices list of 3 options is checked for duplicates (which if present are removed) and shown to the user, who must input 1,2 or 3 to choose an answer.

Top comments (0)