Skip to content
Advertisement

Modifying the contents of a list Python

Here’s the coursera Google question prompt that I’m having issues with:

The skip_elements function returns a list containing every other element from an input list, starting with the first element. Complete this function to do that, using the for loop to iterate through the input list

Original Code:

JavaScript

What I have:

JavaScript

Advertisement

Answer

With minimal change to your code and no enumerate:

JavaScript

The classical way:

JavaScript

Output:

JavaScript

And because we like it: the one-liner

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement