0

Need a hint

I can't figure out how to escape a loop from deeper inside. It very well may be that I have modeled my code badly. example: def func1() display data def func2() action Y or N if Y do action elif N break OR SOMETHING def func3() do a totally different action while x != something func1() func2() func3 If this is too high level (vague), let me know and I will post the actual code I am working on.

30th Oct 2017, 2:09 PM
Turner Lee
Turner Lee - avatar
2 Respuestas
+ 3
Your loop was designed to run until x equals "something" but I don't see either func1 or func2 does anything to change x in any way that it could become equal to "something". Maybe you need to make func1 and func2 to return something which you can later use to decide that it's time to exit the loop, or have them work on x so its value can shift closer towards "something". Not really sure what to suggest, so I give it just general view.
30th Oct 2017, 2:50 PM
Ipang
0
@Ipang Thanks, it was all in the use of return, it just took me a couple of more days to see how to utilize a returned value to break the nested loop. This is what I came up with: https://code.sololearn.com/c6vXaf9e0nLS Let me know if you see an cleaner/better way to accomplish this.
1st Nov 2017, 3:39 PM
Turner Lee
Turner Lee - avatar