I need to create a progtam that opens a file then reads the values inside the file and then prints out the name with the largest value.
The file contains the following info:
Juan,27Joe,16 Mike,29Roy,10
Now the code I have is as follows:
UserFile = input('enter file name')FileOpen = open(User File,'r')for lines in User File: data = line.split(",") name = data[0] hrs = data[1] hrs = int(hrs) LHRS = 0 if hrs > LHRS: LHRS = hrs if LHRS == LHRS: print('Person with largest hours is',name)
The following prints out:
Person with the largest hours is JuanPerson with the largest hours is Mike
How can I make it so it only prints out the true largest?