Advanced Python Code Challenges: Lists - 1. Every Three Numbers


I am currently working on the above exercise and I cant seem to get the list to generate, am i missing something?

I bet its something really silly.

as you can see on the right hand side, range() does not return a list

we could convert the range object into a list.

It’s not silly.

You are missing one component, a constructor before range()

Hi, thanks,

Could you show me using this example of how the list would be structured?

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

I have tried to apply a list to the return line, but I am getting an typeerror.

So first you wrap the range object in a list, and then you try to convert the list into a list? Why?

1 Like

Ok sussed it, got my brackets muddled up.

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

I would still argue you have on set of parentheses too many

1 Like

I an not entirely sure what you mean, please understand I am still learning and I don’t know all the technical jargon yet.

parentheses/brackets, these things: ()

isn’t such a technical term, right?

you have 3 sets of parentheses, while you only need two. the “middle” set of parentheses doesn’t serve any purpose at the moment

1 Like