asked 85.6k views
4 votes
write a function append1() that takes an argument n. the function body should: i i (ii) loop from i in 1 to n and at each iteration use c(x,i) to extend x by one element, and i (iii) return x.

asked
User It Grunt
by
8.4k points

1 Answer

6 votes

Final answer:

To write the function append1() that takes an argument n and returns a list, you can use a loop to iterate from 1 to n. Within the loop, you can use the append () method to extend the list by one element at each iteration. Finally, you can return the list.

Step-by-step explanation:

To write the function append1() that takes an argument n and returns a list, you can use a loop to iterate from 1 to n. Within the loop, you can use the append() method to extend the list by one element at each iteration. Finally, you can return the list.

def append1(n):
x = []
for i in range (1, n+1):
x.append(i)
return x

answered
User Legxis
by
7.6k points