Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Python code?
def example(L):
”’ (list) -> list
”’
i = 0
result = []
while i < len(L):
result.append(L[i])
i = i + 3
return result

What will be the output of the following Python code?
def example(L):
”’ (list) -> list
”’
i = 0
result = []
while i < len(L):
result.append(L[i])
i = i + 3
return result
a) Return a list containing every third item from L starting at index 0
b) Return an empty list
c) Return a list containing every third index from L starting at index 0
d) Return a list containing the items from L starting from index 0, omitting every third item

Answer: a
Explanation: Run the code to get a better understanding with many arguments.

Join The Discussion