Oct-14-2017, 07:38 PM
(Oct-14-2017, 05:20 PM)auting82 Wrote: Thanks, that worked.
Actually looking at it for second time, I think you need to unindent also line 7 in order to implement midpoint method
(Oct-14-2017, 05:20 PM)auting82 Wrote: As I am new to python, I am a bit confused on how to know if its an identation error as the program dosen't tell me Think ??
There is no indentation error in your code - it is valid python code and thus the interpreter does not raise any error. However it is incorrect in the sense that it does not implement the desired algorithm - because the return statement is within the for loop body, it actually exit the loop and the function after the first iteration, i.e. it does not finish the iteration. Understanding how your code works and what you want to do/implement will help you to identify such bugs. This comes with the experience and in more professional sense - the proper tests will help identify such errors in the code.
Now, your code in the post # 4 will indeed raise IndentationError because Python expects indented block after line 8. In fact you need to indent lines 9-12 one level, thus they will be executed for each iteration of the loop.