Courses/learn-python-3/lessons/learn-python-loops/exercises/while

Hello community,
I’m still quite new here, so I hope I understand it well. If not, I apologize forwardly.
*In exercises for python 3, section loops, 7th task WHILE has a nice example. *
I followed instructions and only because of them, I found that code works even it shouldn’t (at least I assume)
I applied following code:
index = 0
while index < len(all_students):

  • students_in_poetry.append(all_students.pop())*
  • index += 1*

and this works. right side of the condition: while index < len(all_student) solves exercise, meanwhile this is a bit misleading. while index < 6: ( - putting the value after comparative operator works as it should.)
in the instructions: You are adding students to a Poetry class, the size of which is capped at 6. While the length of the students_in_poetry list is less than 6 ,… (we might find out that list students_in_poetry seems to be pre-set for 6)
My question (if this is the bug) in the topic of particular exercise wasn’t answered, so I lead my curiosity to understand correctly here.

Topic Title: Course name + section + what type of bug(is it a typo, instructions error, broken URL, SCT issue)
i dont know what type is this.
Summery of the report:
a condition in the example for this exercise allows students to pass with solution that doesn’t correspondent with instructions.
Course URL:
(https://www.codecademy.com/courses/learn-python-3/lessons/learn-python-loops/exercises/while)
Steps to Reproduce: N/A
Fix or Workaround: N/A
Please attach screenshots Not necessary

If you’re just curious about a lesson then get-help is generally the right place to post or see this FAQ for asking questions on the forums.

I’m not sure what you think is a bug in this code though it’s difficult to read without formatting, see: How do I format code in my posts? There’s more than one route to solve a problem and it’s good that you’re trying different routes to do so. Whilst you could arguably make this more modular by removing some hard coding and wrapping it in a function not every single lesson forces you to do so as it wouldn’t meet the purpose of that particular lesson (you can learn about while loops without writing a function every time).

Could you perhaps clarify what part of this lesson you think is not working as intended?

1 Like