Xavi's checking for injured players!

Report a typo

Following Xavi Hernández's management, in 🔵🔴 🔵F.C. Barcelona 🔵🔴 🔵 there are some injured players that can't participate in any football matches.

The injured players are listed on the predefined injuredPlayers map, the key is a string with the name of the player and the value is an int with the expected recovery time in days.

Can you help Xavi implement a program that takes the player name as an input, checks if the player is on the injuredPlayers map, and prints a message with the player's name and the expected recovery time? In case the player is not on the map, the program should print a message explaining that the player isn't injured.

Below you can see an example of the expected output:

// Output in case the player is injured (player is in the 'injuredPlayers' map):
The player Aguero will recover in 93 days

// Output in case the player is not injured (player is not in the 'injuredPlayers' map):
The player Memphis is not injured

Sample Input 1:

Aguero

Sample Output 1:

The player Aguero will recover in 93 days
Write a program in Go
package main

import "fmt"

func main() {
// do not change the values inside the map!
injuredPlayers := map[string]int{
"Aguero": 93,
"Dembele": 45,
"Pedri": 4,
}

var player string

fmt.Scanln(?) // take input of the player name here within the 'player' variable

// implement the val, ok check below to verify if the player is on the map
if ?, ? := injuredPlayers[?]; ? {
fmt.Println("The player", ?, "will recover in", ?, "days")
return
}
fmt.Println("The player", ?, "is not injured")
}
___

Create a free account to access the full topic