+ 1

python please help

so brace yourselves for some pretty beginner looking code. My task is to create multiple functions in order to ask 10 different users for their names and ages and store them into lists. My task is then; using this information, create two functions that will find the oldest person in the list and print the output as their name and how old they are, and the same for the youngest person, And to validate so that the users can only enter an age within a certain range. This is my code thus far:

11th Oct 2017, 3:42 PM
Leeroy
1 Answer
+ 1
oldest = 0 def GetInputs(): #Finds out the ages and names needed in the program Firstnames=[""]*10 Ages=[0]*10 for counter in range(0,10): #loops through 10 times print("Please enter the name of student ", counter+1,": ") Firstnames[counter]=str(input()) print("Please enter the age of this student ", counter+1,": ") Ages[counter]=int(input()) return Firstnames, Ages def FindOldest(Firstnames, Ages): length = len(Ages) Oldest = Ages[0] #Initialises max to first element Oldest = max(Ages) #Finding the max age within the array OldestName = Firstnames[0] for counter in range(1, length): if Ages return Oldest def FindYoungest(Firstnames, Ages): Youngest = Ages[0] Youngest = min(Ages) #Finding the min age within the array return Youngest def DisplayOutputs(Firstnames, Oldest, Youngest): print("The oldest persons name is: ") print("They are: ", Oldest,"Years old") print("The youngest persons name is: ") print("They are: ", Youngest,"Years old") Firstnames, Ages = GetInputs() Oldest = FindOldest(Firstnames, Ages) Youngest = FindYoungest(Firstnames, Ages) DisplayOutputs(Firstnames, Oldest, Youngest) My problem is evidently the two middle functions, the first function works just fine and I can actually understand it, so if you're out there and answering this please bare in mind my understanding of more advanced topics will probably blow my mind and leave me knowing less than I did before. So thanks in advance, you're my heroes.
11th Oct 2017, 3:43 PM
Leeroy