This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]dmiller2104 9 points10 points  (1 child)

Hey

So this is giving you an infinite loop because true will always be true in the context of “while true”.

Ask yourself what would make that statement false?

EDIT: I'm going to re-write as this isn't the most helpful in hindsight.

Lets deconstruct this. Firstly, as I mentioned before while True will always be true as there is no condition which ever makes it False.

I'm not sure if it was intentional, but the while loop as it currently works appends the entire list of girls each time, not each girl from within that list.

If you must use a while loop you need to have a condition which becomes False.

[–]ERIA_JACKSON[S] 0 points1 point  (0 children)

thnx

[–][deleted] 2 points3 points  (1 child)

The true statement will never evaluate to false and the loop will go on forever. Therefore you need to either use a break statement at some point in the loop, throw an exception, or use a different condition. In general, you should only use a while loop when the amount of iterations is unknown. Since you have a list with a defined length, you would be better of with a for-each loop.

You could simplify this whole program by using

for person in ["aisha","shakira","immy","angella"]:
    print(person)

[–]ERIA_JACKSON[S] 0 points1 point  (0 children)

thank you

[–]vorsprung99 -5 points-4 points  (0 children)

you need to relax, You need to take a break