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?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# 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() |