Season from Month

Use switch with boolean expressions to determine the season.

package main

import "fmt"

func main() {
	month := 7

	switch {
	case month >= 3 && month <= 5:
		fmt.Println("Spring")
	case month >= 6 && month <= 8:
		fmt.Println("Summer")
	case month >= 9 && month <= 11:
		fmt.Println("Autumn")
	default:
		fmt.Println("Winter")
	}
}
▶ Open Go Playground

Copy the code above and paste to run

© 2026 ByteLearn.dev. Free courses for developers. · Privacy