Loop not ending

The while loop is not ending even if num2find != -1 , it keeps on doing 27 , 28 (see numbers).
para1 is just a paragraph (don’t mind that)

Given that input always returns a string, think about the comparisons in your loop.

P. S. You’ve prefixed some variables as num etc., but it seems you’re trying to find a word [?]. Is that a number, or any word? This is a little unclear to me.

if you want to have num2find get a different value inside the loop, you need to either execute the assignment again (just like you repeat the inupt statement) or turn it into a function.

No, the while loop will never end, because when num2find has a value of -1, there’s nothing inside of said loop that alters the value of num2find

You say “see numbers”. What numbers? If you mean the line numbers, then that really goes without saying.

Re-code line 29 as: if num2find != -1:, which is the same thing, only it’s easier to read, although while num2find has a value of -1, that branch will never execute.

Last point of order: please refrain from posting code as a image

1 Like