I need help with code practice 36.2 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I need help with code practice 36.2

I can not out put it in string only in colum

6th Feb 2022, 5:41 PM
Oll 25
3 Answers
+ 4
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:41 PM
Oll 25
+ 4
In your route () function, change fmt.Println () to fmt.Print (). Just remove "ln"
6th Feb 2022, 6:08 PM
CGM
CGM - avatar
+ 4
// here good resolved package main import "fmt" //create the route() function func route(cities... string ){ var r string = "" for _,v := range cities { r += (v+"->") } fmt.Println(r) } 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...) }
3rd Feb 2023, 11:15 AM
Daniel Rodriguez Amezaga
Daniel Rodriguez Amezaga - avatar