0
I need help with code practice 36.2
I can not out put it in string only in colum
3 Respostas
+ 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...)
}
+ 4
In your route () function, change fmt.Println () to fmt.Print ().
Just remove "ln"
+ 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...)
}