{}
run-icon
main.go
package main import ( "fmt" "slices" ) func main() { colors := []string{"white", "yellow", "orange", "march", "red", "green", "april", "brown", "blue", "black", "september"} months := []string{"january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"} fmt.Printf("NOTE: 'slices.Contains()' and 'slices.Delete()' are available as of Go v1.21\n\n") count := 0 for _, color := range colors { if slices.Contains(months, color) { colors = slices.Delete(colors, count, count + 1) } count += 1 } fmt.Println(colors) }
Output