Mar-08-2020, 03:33 PM
Hi,
I have a syntax error on line 67 and can't seem to figure out why? can someone please help and explain why please?
I have a syntax error on line 67 and can't seem to figure out why? can someone please help and explain why please?
# games_database.py def load_games(filename): pass def save_games(filename, games): pass def display_games(games): pass def get_game_from_user(): pass def display_menu(): print() print("***Welcome to the Computer Game Database***") print() print("1. Add new games") print("2. Display games") print("3. Exit program") print() def main(): exit_program = False while not exit_program: display_menu() selected_option = int(input("Please select a menu option: ")) if selected_option == 1: import csv class game(): def _init_(self): self.name = '-' self.platform = '-' self.genre = '-' self.players = '-' self.online = '-' #main gameList = [] for count in range (0,3): aGame = game() aGame.name = input("Enter game name: ") aGame.platform = input("Enter game platform: ") aGame.genre = input("Enter game genre: ") aGame.players = input("Enter number of players: ") aGame.online = input("Can you play online?: ") gameList.append(aGame) #display for count in range (0,3): print(gameList[count].name) print(gameList[count].platform) print(gameList[count].genre) print(gameList[count].players) print(gameList[count].online) print("-----------") #write to csv with open('gameList.csv', 'w', newline='') as file: writer = csv.writer(file) for count in range(0, 3): writer.writerow([gameList[count].name, gameList[count].platform, gameList[count].genre, gameList[count].players, gameList[count].online]) elif selected_option == 2: gameList = list() filename = 'gameList.csv' with open (filename) as fin: for line in fin: gameList.append(line) gameList.sort() print(gameList) elif selected_option == 3: pass else: print("Please enter a valid option (1-3)") print() if __name__ == "__main__": main()