Hackbright Code Challenges

Show Even Numbers

Show Even Numbers

Whiteboard

Easier

Challenge

Easier

Concepts

Loops

Download

show-evens.zip

Solution

Show Even Numbers: Solution


You will be given a list of integers, some even and some odd:

>>> lst = [1, 2, 3, 4, 6, 8]

Write a function that returns the indices (0-based, as usual in Python) of all the numbers which are even.

So, for our list above, that would be:

>>> show_evens(lst)
[1, 3, 4, 5]

We’ve given you a fill, showevens.py, with a function, show_evens, in it:

def show_evens(nums):
    """Given list of ints, return list of *indices* of even numbers in list."""

However, this function is unimplemented.