Created
December 22, 2023 04:16
-
-
Save mofodox/8dcf894b2f5188156de9579e7fec5967 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
numOfPlayers := 0 | |
index := 1 | |
fmt.Print("Enter number of players: ") | |
fmt.Scan(&numOfPlayers) | |
var playerNames []string | |
for i := index; i <= numOfPlayers; i++ { | |
var playerName string | |
fmt.Printf("Enter player %v name: \n", i) | |
fmt.Scan(&playerName) | |
playerNames = append(playerNames, playerName) | |
} | |
names := strings.Join(playerNames, ", ") | |
fmt.Printf("Player names are: %s\n", names) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment