Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
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
4 Respostas
+ 4
Can you share your attempt?
+ 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])
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
0
I don't know why you want to compare the input with anything, you just have to output the corresponding game