Python Forum
Methods that return the highest score from the list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Methods that return the highest score from the list
#1
Hello guys !
I just got an exercise to do and I wrote some code for this task but unfortunately I'm facing some errors !
The task is :
# to write methods that return the highest score from the list, the last added score and the three highest 
# scores.
I solved the first ones ( return highest score and the last added score successfully . ) but I got stuck in last one which is to return the three highest scores
and this is my code and functions for doing it
def Three_highest_scores(a, b, c):
    for j in gamePlayersList:
        a = max(gamePlayersList)
        print(j)
        return a

        for f in gamePlayersList:
            if f < a:
                b = max(f)
                print(f)
                return b

                for x in gamePlayersList:
                    if a > x < f:
                        c = max(x)
                        print(x)
                        return c


Three_highest_scores(max(gamePlayersList), max(f), max(x))
print(Three_highest_scores())
And this is the error :
 Three_highest_scores(max(gamePlayersList), max(f), max(x))
NameError: name 'f' is not defined 
So , I'm very thankful if you can help me fix these issues .
Thanks
Reply


Messages In This Thread
Methods that return the highest score from the list - by erfanakbari1 - Mar-24-2019, 02:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to update score value? Mavoz 5 2,505 Nov-08-2022, 12:37 AM
Last Post: Mavoz
  How to sort a list with duplicates and return their unique indices. Echoroom 3 3,535 Sep-23-2022, 07:53 AM
Last Post: deanhystad
  Return the sum of the first n numbers in the list. pav1983 3 4,148 Jun-24-2020, 03:37 AM
Last Post: deanhystad
  How to assign a "Score" variable to each element in a list Reta 5 5,375 May-16-2019, 01:13 PM
Last Post: ichabod801
  Return not vowels list erfanakbari1 2 2,709 Mar-26-2019, 11:37 AM
Last Post: perfringo
  List not passing between methods inside a class definition ijosefson 5 4,451 Oct-15-2017, 07:15 PM
Last Post: ijosefson
  how to get the highest monthly average temperature? nikhilkumar 2 7,067 Jul-25-2017, 02:33 PM
Last Post: DeaD_EyE
  Returning the highest value out of 3 values ComputerSkillet 2 3,872 Apr-28-2017, 03:16 AM
Last Post: volcano63
  Numerically determining the highest a ball travels when shot straight up JakeWitten 3 3,448 Apr-22-2017, 04:37 PM
Last Post: Ofnuts
  Average score MartinEvtimov 5 6,872 Apr-02-2017, 07:35 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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