0
Practice 36.2 Golang help please!
3 Answers
+ 2
package main
import "fmt"
//create the route() function
func route(cities...string){
for _,v := range cities{
fmt.Println ( v, "->" )}
}
func main() {
var n int
fmt.Scanln(&n)
var cities []string
//take n strings as input and append them to the slice
for i:=0; i<n; i++{
var input string
fmt.Scanln(&input)
cities = append (cities,input,)
//
}
route(cities...)
}
+ 2
In your route () function, change fmt.Println () to fmt.Print ().
Just remove "ln"
0
//the route() function
func route(cities...string){
for _,v := range cities{
fmt.Print ( v, "->" )}
}
func main() {
var n int
fmt.Scanln(&n)
var cities []string
for i:=0; i<n; i++{
var input string
fmt.Scanln(&input)
cities = append (cities,input,)
//
}
route(cities...)
}