0

Practice 36.2 Golang help please!

6th Feb 2022, 5:45 PM
Oll 25
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...) }
6th Feb 2022, 5:45 PM
Oll 25
+ 2
In your route () function, change fmt.Println () to fmt.Print (). Just remove "ln"
6th Feb 2022, 6:08 PM
CGM
CGM - avatar
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...) }
12th Dec 2022, 10:03 AM
Fabio Conte
Fabio Conte - avatar