
Bug hunt
The Silent Calculator
A function that only prints its answer is like a friend who shouts the answer across the room and then forgets it. You can see it, but you can't use it.
If a function should produce a value for other code, it must
return it. Every function without a return gives back None.
The bug
The lighthouse keeper's fuel calculator prints numbers, then crashes:
12
10
TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'
morning and evening are both None, and you can't add Nones!
Assignment
Fix total_fuel so it returns the fuel instead of printing it.
The program should then print Fuel for today: 22.
Fix total_fuel so it returns the fuel instead of printing it.
The program should then print Fuel for today: 22.
main.py Python sleeping
Press Run to try your code, then Check to test it.