Assigning Values to Multiple Variables

Assigning Values to Multiple Variables

In python, assigning values to several variables can be done in a compact way using list manipulation.

x1 = np.zeros(30)
v1, w1, u1 = np.split(x1,3)[:3]
print v1, w1, u1

Planted: by ;

L Ma (2015). 'Assigning Values to Multiple Variables', Datumorphism, 12 April. Available at: https://datumorphism.leima.is/til/programming/python/python-assigning-values-to-multiple-variables/.