Go cheatsheet- https://devhints.io/go
1.
For loop in Go
package main
import "fmt"
func main() {
even_numbers := []int{}
for i := 1; i <= 10; i++ {
if i%2 == 0 {
even_numbers = append(even_numbers, i)
}
}
fmt.Println(even_numbers)
}
For loop in Python
even_numbers = []
for number in range(10):
if number % 2 == 0:
even_numbers.append(number)
print(even_numbers)
Top comments (0)