Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in my code
#2
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:
  • 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()?
Reply


Messages In This Thread
Error in my code - by TumbleR - Nov-26-2019, 10:19 PM
RE: Error in my code - by stullis - Nov-26-2019, 10:40 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020