Python Introducing Lists Build an Application Add Items

Michael Casella
Michael Casella
1,358 Points

Why was add_to_list in the while loop not an else statement?

Why was add_to_list in the while loop not an else statement?

1 Answer

Steven Parker
Steven Parker
182,603 Points

An "else" is not needed there since both the "if" and "elif" conditions change the program flow, so all the code below them is done only in an "else" condition. This is a common technique to make the code more compact and easier to maintain.