How do I take the index numbers as input and output the game names?

How do I take the index numbers as input and output the game names?
python
Ethan Jackson

The following program must output the corresponding index number associated with the items in the list titled "games"

#installed games games = [ 'Soccer', 'Tic Tac Toe', 'Snake', 'Puzzle', 'Rally'] #taking player's choice as a number input choice = int(input()) #output the corresponding game if choice == games[choice]: print(games[0, 1, 2, 3, 4])

Answer

#installed games games = [ 'Soccer', 'Tic Tac Toe', 'Snake', 'Puzzle', 'Rally'] #taking player's choice as a number input choice = int(input()) if choice <= len(games) - 1 and choice >= 0: print(games[choice]) else: print('Index Error')

Related Articles