Any other way to solve the same problem


#1

Hi everyone,
I was wondering if there is any other way to solve the same problem

Here’s my solution:


all_students = ["Alex", "Briana", "Cheri", "Daniele", "Dora", "Minerva", "Alexa", "Obie", "Arius", "Loki"]
students_in_poetry = []

capacity = 6
while len(students_in_poetry) < capacity:
  student = all_students.pop()
  students_in_poetry.append(student)
  
print(students_in_poetry)

FAQ: Learn Python: Loops - While Loops
#2

Which problem?
Reversing it?
If you’re making some kind of copy then you shouldn’t need to modify the original. However, it does come with the benefit that there’s no need to keep track of a position in the list which is something that I generally like (hard to make mistakes when doing it that way)
If it’s reversed, then 6 seems like an oddly specific number, where does that come from?
If the copy is supposed to become some size then I’d probably phrase the condition as while that list is too small.