Coding Exercise #14
🌶️🌶️
👉 Complete the definition of the square_list function. The function should square the elements of the input list and return the new list. For example, if the function gets the data list as an argument, it should return [1, 4, 9, 16].
data = [1, 2, 3, 4]
def square_list...Press the button below to code the exercise now in the online IDE:
Use the button below to see the solution:
Subscribe below to get a new Python project or exercise daily or upgrade to our paid plan to view the archive of projects, exercises, and solutions.



data = [1, 2, 3, 4]
def square_list(lst):
y = []
for x in (range(len(lst))):
y.append(lst[x] ** 2)
return(y)
n = square_list(data)
print(n)
https://trinket.io/python3/95c7179ec6