Nov-14-2019, 02:24 PM
Hi everyone, im having trouble with some basic code. basically im having a few errors in the code asking questions twice or not picking up certain information. if someone can help it will be greatly appreciated
the programme needs to allow someone to enter gender, amount of racers, to sort times fastest to slowest and notify if a record is broken.
the programme needs to allow someone to enter gender, amount of racers, to sort times fastest to slowest and notify if a record is broken.
counter=0 specTime=0 laneNum=[] gender = 0 genderList = ["m" ,"M", "f" , "F"] while gender not in genderList: gender=input("Please enter whether it is a male or female race. M/F ") if gender=="M" or "m": worldrecords=[9.58,9.86,9.87] while True: numRacers= int(input("Please input how many racers will be participating? There's a limit from 4-8 racers. ")) if (numRacers < 4) or (numRacers > 8): print("The minimum racers allowed is 4, and the maximum is 8. Please enter the correct racers again") continue break for count in range(numRacers): specTime=counter+1 time=float(input("Please enter the lap time for lane " +str(specTime)+ " to 2 decimal places. ")) num=round(time, 2) # turns the time into two decimal places if the user has put more than two DP laneNum.append(num) if laneNum[counter]<= worldrecords[0]: print("Congratulations! World record, European record and British record has been achieved!") elif laneNum[counter]<= worldrecords[1]: print("Congratulations! European record and British Record has been achieved!") elif laneNum[counter]<= worldrecords[2]: print("Congratulations! British record has been achieved!") counter=counter+1 laneNum.sort() print(laneNum) if gender=="F" or "f": worldrecords2=[10.49,10.73,10.99] while False: numRacers= int(input("Please input how many racers will be participating? There's a limit from 4-8 racers. ")) if (numRacers > 4) or (numRacers > 8): print("The minimum racers allowed is 4, and the maximum is 8. Please enter the correct racers again") continue break while counter!=numRacers: specTime=counter+1 time=float(input("Please enter the lap time for lane " +str(specTime)+ " to 2 decimal places. ")) num=round(time, 2) # turns the time into two decimal places if the user has put more than two DP laneNum.append(num) if laneNum[counter]<= worldrecords2[0]: print("Congratulations! World record, European record and British record has been achieved!") elif laneNum[counter]<= worldrecords2[1]: print("Congratulations! European record and British Record has been achieved!") elif laneNum[counter]<= worldrecords2[2]: print("Congratulations! British record has been achieved!") counter=counter+1 laneNum.sort() print(laneNum)