Nov-26-2019, 10:40 PM
The final result is None because list.sort() sorts in place, meaning no value is returned. When a variable is set based on a function/method that returns nothing, it is set as None.
In general, this needs some refactoring before it will work. Consider these questions:
In general, this needs some refactoring before it will work. Consider these questions:
- Why sort the code for every new addition?
- Does list.sort() take any arguments? Which ones? (Research standard library documentation.)
- If variable c is instantiated in number(), how would the while loop outside of number know about c? Is that proper coding or just a quirk of Python? And, if it's a quirk, how would the loop know about c changing to a different value? (Think about scope.)
- Where is there any division in number()?