DEV Community

Vishal Dhapola
Vishal Dhapola

Posted on

Python vs GO

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)
}
Enter fullscreen mode Exit fullscreen mode

For loop in Python

even_numbers = []
for number in range(10):
   if number % 2 == 0:
      even_numbers.append(number)
print(even_numbers)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)