Write a script that will allow a user to search in a text file to find video games that match their interests.
Prompt the user to enter one to four tags
Split the user input into a list of user tags
Calculate the number of user tags
Open the games text file
Initialize an empty list of matching games
For each line in the games text file
Set the matchcount variable to zero
Split the line into a list of game info
For each tag in the user tag list
If the tag is in the game info list
Increment the matchcount variable
If the matchcount is equal to the number of user tags
Add the name of the game to the list of matching games
If there are no matching games
Print Sorry, no games match your criteria
Print the count of matching games and a list of the games
This project is similar to the Computer Class project demonstrated in the videos referenced on page 17 of the Containers and Lists slideshow. Much of the code for this project can be taken from the Computer Class project, but a key difference is that instead of matching on a single criteria, this project can require matches on multiple criteria.
The name of the game text file is Lab9_CatGames.txt and the file is located in Canvas.
You will need to copy this file to your local working directory.
Log in to Catalyst.
Select CIS 40.
Move your cursor to the right of the green checkmark icon.
Click the down arrow next to the gear.
Click Save File and OK
The file should be on your desktop or download directory
The game file has 75 games, and there are 12 possible descriptive tags (Action, Adventure, Arcade, Casual, Funny, Horror, Indie, Puzzle, Racing, RPG, Simulation, Strategy). Tags for each game are unique - there are no duplicates.
OPTIONAL CHALLENGE: If you would like to extend the basic lab, a possible enhancement is listed below. This is simply for your learning and enjoyment, not for extra credit.