Senior
November 18, 2026Spot the bug: Go
One snippet. Find the bug, or prove there isn't one.
go
1package main
2
3import "fmt"
4
5func printItems(items []string) {
6 if items == nil || len(items) == 0 {
7 fmt.Println("empty")
8 return
9 }
10 for _, item := range items {
11 fmt.Println(item)
12 }
13}
14
15func main() {
16 printItems(nil)
17 printItems([]string{"a", "b"})
18}Click the lines that carry the problem.
Your verdict
One attempt per day. The answer shows up right after.
Keep your streak
Create an account to keep your streak and track your progress.