Why does my code not return anything

后端 未结 5 1543
终归单人心
终归单人心 2021-01-29 16:28

fairly new to programming and trying to learn Python at the moment. I have this code and I don\'t understand why I don\'t get a return value :(

balance = 3200
an         


        
5条回答
  •  悲&欢浪女
    2021-01-29 17:07

    Two reasons. One, your function f(x) does not have an explicit return statement. If a function doesn't contain an explicit return it will have an implicit one, that is "None" (None is a python object). Second, the only place where f(x) is called is in bisection() which itself is never being called. So, since none of your functions are ever called, your code isn't going to return anything. Try calling bisection() after defining it

提交回复
热议问题