Member-only story
Go For Python Developers
Part-3: Composite Datatypes

Lists
The List is the ordered collection of multiple elements. The equivalent in Go is Slice. The main feature of Slice
is it dynamic size?

Negative Indexing
Python list
generally has more features compared to Slice
in Go. Python supports negative indexing. For Go, we have to access it as follows:
Insert
Python also has an insert
function that allows us to add value to any specific position. Go doesn’t have such abstraction.
Array
Array is a fixed sized Slice
. The size is defined inside the square braces.
We can make the compiler find the size from the initialized value as:
The closest thing to the fixed size we have in python is a tuple. Tuple supports indexing but doesn’t allow the change in values.
>>> a = (0, 1, 2)
>>> a[1]
1
>>> a[1] = 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>>