Python Forum
I am stuck on functions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I am stuck on functions
#9
K.  So scoreCalculator(scores) should not be in the while loop.  That needs to be unindented.

In your function, as Wavic said, if you are using the sum builtin you don't need the for loop. So total = sum(scores) would do it.
Also you want to divide total by the length of scores, not score.

Finally you need to convert your input to an int.
Assuming you don't need any input validation this will do it:
number = int(input("Enter a score (0 - 10) -> "))
Try to make these changes and post your code.

Also let us know if there is an error and how your program is behaving.
Reply


Messages In This Thread
I am stuck on functions - by Hebruiser - Nov-11-2017, 02:07 AM
RE: I am stuck on functions - by Larz60+ - Nov-11-2017, 02:20 AM
RE: I am stuck on functions - by wavic - Nov-11-2017, 02:24 AM
RE: I am stuck on functions - by wavic - Nov-11-2017, 11:15 AM
RE: I am stuck on functions - by Larz60+ - Nov-11-2017, 11:56 AM
RE: I am stuck on functions - by Hebruiser - Nov-11-2017, 02:48 PM
RE: I am stuck on functions - by Mekire - Nov-11-2017, 03:00 PM
RE: I am stuck on functions - by Hebruiser - Nov-11-2017, 03:30 PM
RE: I am stuck on functions - by Mekire - Nov-11-2017, 04:06 PM
RE: I am stuck on functions - by Hebruiser - Nov-11-2017, 06:42 PM
RE: I am stuck on functions - by wavic - Nov-11-2017, 08:32 PM
RE: I am stuck on functions - by Hebruiser - Nov-11-2017, 08:46 PM

Forum Jump:

User Panel Messages

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