Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Golang Level 4/Lesson 4

says my program output in wrong , but all i need is include math/rand package path :

package main
import (
"fmt"
"math/rand"
)

func main() {
target := rand.Intn(100) + 1
fmt.Println(target)
}
by

8 Answers

r4gzysc
fmt.Println(target + 1) .... this edit worked
WilliamHarry168
Same me too, idk why

package main

import (
"fmt"
"math/rand"
)

func main() {
target := rand.Intn(100) + 1
fmt.Println(target + 1) // Menambahkan teks untuk mencocokkan ekspektasi output
}
WilliamHarry168
but still error "
Your code's output does not match the expected outcome for this exercise."
r4gzysc
you don't need to do this twice "target := rand.Intn(100) + 1
fmt.Println(target + 1) " your basicly prints target +2 .
hope this hint helps
WilliamHarry168
If i do like who ask the question the result is says "
Your code's output does not match the expected outcome for this exercise."


package main
import (
"fmt"
"math/rand"
)

func main() {
target := rand.Intn(100)
fmt.Println(target)
}
r4gzysc
try this :
package main
import (
"fmt"
"math/rand"
)

func main() {
target := rand.Intn(100) + 1
fmt.Println(target)
}
or this
package main
import (
"fmt"
"math/rand"
)

func main() {
target := rand.Intn(100)
fmt.Println(target + 1)
}

again you're not adding one in either case , while i suggested to only add it in one of the lines .
nikhil1519
package main
import (
"fmt"
"math/rand"
)

func main() {
target := rand.Intn(100) + 1
fmt.Println(target)
}

This is final solution for Level 4>Lesson 5.
I'm getting error:
Your code's output does not match the expected outcome for this exercise.
WilliamHarry168
i'm still getting same error too

Login / Signup to Answer the Question.