FAQ: Code Challenge: Lists - Every Three Nums


This community-built FAQ covers the “Every Three Nums” exercise from the lesson “Code Challenge: Lists”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science
Data Science

FAQs on the exercise Every Three Nums

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


This is a very frustrating. I hate being quizzed on things that were never addressed during the lesson. Unless you know of the range() function before starting, just use the “hint” button. This should be incorporated as part of the learning journey… or maybe at the end say look up “range() and int().” “int()” was not included as part of this review either.


I looked up range and used one of the examples i found. I’m pretty sure I have cheated here by setting my second value to 103 ; so i am interested in what the real solution should look like.

def every_three_nums(start):
  if start > 100:
    return []
    list_of_ints = list(range(start,103,3))
    return list_of_ints

#Uncomment the line below when your function is done


I solved it with this function:

def every_three_nums(start):
return list(range(start, 101, 3))

#Uncomment the line below when your function is done


What is curious is that the correct answer/solution does not address the last function requirement.

Ifstartis greater than100, the function should return an empty list.

My code does address this:

def every_three_nums(start):
  """function should return a list of every third number between\n start and 100 (inclusive). For example, every_three_nums(91) should return the list [91, 94, 97, 100]. If start is greater than 100, the function should return an empty list."""
  return list(range(start,101,3))
  if start>100:
    return []



Hi @pleabargain,

Your code doesn’t actually need this if block:

  if start>100:
    return []

If the start argument passed to the range constructor is equal to or greater than the end argument, and the step argument is positive, the result is an empty range object. In the current case, this occurs if the start value is greater than 100.

That is sufficient to enable the first return statement within your every_three_nums function, by itself, to satisfy this requirement:

If start is greater than 100 , the function should return an empty list.


You can code the empty list but it’s not necessary. Using the range function will return an empty list if the number is above 100.
Try this and you will see:

def every_three_nums(start):
return list(range(start, 101, 3))