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
#8
I think you can make your code more simplified , please find the below code

gamePlayersList = [157, 298, 108, 400, 2, 30, 12, 70]
print(gamePlayersList)


def frogger():
    for i in gamePlayersList:
        highest = max(gamePlayersList)
        last = gamePlayersList[-1]
        print(highest)
        print(last)
        S=(sorted(gamePlayersList, reverse=True))
        print(S[0:3])
        break


d=frogger()
Output:
[157, 298, 108, 400, 2, 30, 12, 70] 400 70 [400, 298, 157] Process finished with exit code 0
Reply


Messages In This Thread
RE: Methods that return the highest score from the list - by aankrose - Mar-26-2019, 08:32 PM

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