A game machine has 5 games installed on it, represented in this list: games = ['Soccer', 'Tic Tac Toe', 'Snake', 'Puzzle', 'Ra | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

A game machine has 5 games installed on it, represented in this list: games = ['Soccer', 'Tic Tac Toe', 'Snake', 'Puzzle', 'Ra

A game machine has 5 games installed on it, represented in this list: games = ['Soccer', 'Tic Tac Toe', 'Snake', 'Puzzle', 'Rally'] PY The code that you're about to see takes a number as input, which indicates the choice index. Task Complete the program to output the game from the list that corresponds to that index. img-component

17th Aug 2023, 4:23 PM
Bhargavi Guntakala
Bhargavi Guntakala - avatar
4 Answers
+ 4
Can you share your attempt?
17th Aug 2023, 5:47 PM
Sakshi
Sakshi - avatar
+ 1
# Juegos instalados games = [ 'Soccer', 'Tic Tac Toe', 'Snake', 'Puzzle', 'Rally'] # Tomar la elección del jugador como un número de entrada choice = int(input()) # Mostrar el juego correspondiente if choice == 0 or choice == 2 or choice == 4 : print(games[choice])
29th Jan 2024, 4:19 PM
Cesar Rodriguez
Cesar Rodriguez - avatar
0
for example: create a choice variable which needs an input as integer, after that if the number is between the game's indexes, then just print it out
17th Aug 2023, 8:18 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
0
I don't know why you want to compare the input with anything, you just have to output the corresponding game
31st Jan 2024, 1:53 PM
Mihaly Nyilas
Mihaly Nyilas - avatar