Using Sort Method Previous Code Put Inside Addhours Method Possible Would Get List Employe Q37160289

Using a sort method and my previous code (put inside of addHoursmethod if possible), how would I get the list of each employee’stotal hours to display in order of least amount of hours togreatest. An explanation for each step would also be great.

import random

#Create function addHours
def addHours(lst):
#Display added hours of employees
print(“nEmployee# Weekly Hours”)
print(“—————————-“)
print(” 1 “,sum(lst[0]))
print(” 2 “,sum(lst[1]))
print(” 3 “,sum(lst[2]))

#Create main function
def main():
#Create first empty list and add random number
one=[]
for j in range(7):
one.append(random.randint(0,10))
#Create second empty list and add random number
two=[]
for j in range(7):
two.append(random.randint(0,10))
#Create third empty list and add random number
three=[]
for j in range(7):
three.append(random.randint(0,10))
#Create a list to combine previous lists
lst=[one,two,three]
#Display output of

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.