I am told to
Write a function, square(a), that takes an array, a, of numbers and returns an array containing each of the values of a squared.
At first, I had
def square(a):
for i in a: print i**2
But this does not work since I'm printing, and not returning like I was asked. So I tried
def square(a):
for i in a: return i**2
But this only squares the last number of my array. How can I get it to square the whole list?
list
andarray
; those are two different data structures. – Extramural