Write a python program that prompts the user for their favorite basketball team. It should be able to read the list of teams provided below in a file called favorite_teams.txt and check if their team is in that file. Teams in the file: Jazz Bulls Mavericks Spurs If the team is in the file let the user know that their team is in the list of favorites. If the team is not in the file, add the team to the end of the file. Also, let the user know that their team will be added to the file. Sample Run in File: What is your favorite NBA team? Jazz [Enter] Your team Jazz is in the list File before and after run: Jazz Bulls Mavericks Spurs Sample Run not in File: What is your favorite NBA team? Pelicans [Enter] Your team Pelicans is not in the list. It will be added. File before run: Jazz Bulls Mavericks Spurs File after run: Jazz Bulls Mavericks Spurs Pelicans
Write a python
Teams in the file:
Jazz
Bulls
Mavericks
Spurs
If the team is in the file let the user know that their team is in the list of favorites. If the team is not in the file, add the team to the end of the file.
Also, let the user know that their team will be added to the file.
Sample Run in File:
What is your favorite NBA team? Jazz [Enter]
Your team Jazz is in the list
File before and after run:
Bulls
Mavericks
Spurs
Sample Run not in File:
What is your favorite NBA team? Pelicans [Enter]
Your team Pelicans is not in the list. It will be added.
File before run:
Bulls
Mavericks
Spurs
File after run:
Jazz
Bulls
Mavericks
Spurs
Pelicans
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images