Hello all,
I was doing the Loops code challenge. On the 3rd challenge you are asked to write a loop that deletes even numbers from the start of the list and return the list once it comes across an odd number. In return, I wrote the two codes below:
I have read the FAQwhich explains some pitfalls of nested loops. Both work if the list argument contains an odd number but if it is all even then the list returns an error. I know it relates to the inner loop running to completion and leaving an empty list which then no longer meets the outer loop condition but cant fully explain it beyond that and I was hoping someone could explain it properly? I have seen the solution which uses an and operator which makes sense! Interestingly, they both return different errors if an all even list which is slightly intriguing since I thought pop(0) and del lst[0] would do the same thing!
Thanks in advance, much appreciated!