def saveUpdVoyage(voyage): today = now() if today > voyage.departureFlight.departure: file = 'PastFlights copy.csv' else: file = 'UpcomingFlights copy3.csv' flights = read_pastFlights(file) newFlights = [] for flight in flights: if flight.flightNumber == voyage.departureFlight.flightNumber and flight.departure == voyage.departureFlight.departure: newFlight = createFlightRoute( voyage.departureFlight.flightNumber, voyage.departureFlight.departingFrom, voyage.departureFlight.arrivingAt, voyage.departureFlight.departure, voyage.departureFlight.arrival, voyage.departureFlight.aircraftId, voyage.departureFlight.soldTickets, voyage.departureFlight.captain, voyage.departureFlight.copilot, voyage.departureFlight.fsm, voyage.departureFlight.fa1, voyage.departureFlight.fa2) newFlights.append(newFlight) elif flight.flightNumber == voyage.returnFlight.flightNumber and flight.departure == voyage.returnFlight.departure: newFlight = createFlightRoute( voyage.returnFlight.flightNumber, voyage.returnFlight.departingFrom, voyage.returnFlight.arrivingAt, voyage.returnFlight.departure, voyage.returnFlight.arrival, voyage.returnFlight.aircraftId, voyage.returnFlight.soldTickets, voyage.returnFlight.captain, voyage.returnFlight.copilot, voyage.returnFlight.fsm, voyage.returnFlight.fa1, voyage.returnFlight.fa2) newFlights.append(newFlight) else: newFlights.append(flight) absPathFile = os.path.abspath(__file__) fileDir = os.path.dirname(os.path.abspath(__file__)) parentDir = os.path.dirname(fileDir) path = parentDir + "/csvFiles/" + file f = open(path, 'w') writer = csv.writer(f) writer.writerow(('flightNumber', 'departingFrom', 'arrivingAt', 'departure', 'arrival', 'aircraftID', 'soldTickets', 'captain', 'copilot', 'fsm', 'fa1', 'fa2')) for flight in newFlights: writer.writerow((flight.flightNumber, flight.departingFrom, flight.arrivingAt, flight.departure, flight.arrival, flight.aircraftId, flight.soldTickets, flight.captain, flight.copilot, flight.fsm, flight.fa1, flight.fa2))
def leitaVoyage(inpt): #fall sem fer i gegnum baðar skrár af flugum og finnur hvaða flug passa við innslegið flugnumer #skilar klasatilviki voyage með bæði flug ut og tilbaka dest = inpt[2:4] no = int(inpt[4:len(inpt)]) voyages =[] done_bool = 0 file1='PastFlights copy.csv' while not done_bool: if file1 == 'UpcomingFlights copy3.csv': done_bool=1 #file_flights=OpenFile(file1) allPastFlights=read_pastFlights(file1) for j in range(len(allPastFlights)): if no%2 == 0 and allPastFlights[j].flightNumber == inpt: voyage = createVoyage() depFlight = createFlightRoute(allPastFlights[j].flightNumber, allPastFlights[j].departingFrom, allPastFlights[j].arrivingAt,allPastFlights[j].departure,allPastFlights[j].arrival,allPastFlights[j].aircraftId, allPastFlights[j].soldTickets, allPastFlights[j].captain, allPastFlights[j].copilot, allPastFlights[j].fsm, allPastFlights[j].fa1, allPastFlights[j].fa2) voyage.departureFlight = depFlight retFlight = createFlightRoute(allPastFlights[j+1].flightNumber, allPastFlights[j+1].departingFrom, allPastFlights[j+1].arrivingAt,allPastFlights[j+1].departure,allPastFlights[j+1].arrival,allPastFlights[j+1].aircraftId, allPastFlights[j+1].soldTickets,allPastFlights[j+1].captain, allPastFlights[j+1].copilot, allPastFlights[j+1].fsm, allPastFlights[j+1].fa1, allPastFlights[j+1].fa2) voyage.returnFlight = retFlight voyages.append(voyage) elif no%2 != 0 and allPastFlights[j].flightNumber == inpt: voyage = createVoyage() depFlight = createFlightRoute(allPastFlights[j-1].flightNumber, allPastFlights[j-1].departingFrom, allPastFlights[j-1].arrivingAt,allPastFlights[j-1].departure,allPastFlights[j-1].arrival,allPastFlights[j-1].aircraftId, allPastFlights[j-1].soldTickets,allPastFlights[j-1].captain, allPastFlights[j-1].copilot, allPastFlights[j-1].fsm, allPastFlights[j-1].fa1, allPastFlights[j-1].fa2) voyage.departureFlight = depFlight retFlight = createFlightRoute(allPastFlights[j].flightNumber, allPastFlights[j].departingFrom, allPastFlights[j].arrivingAt,allPastFlights[j].departure,allPastFlights[j].arrival,allPastFlights[j].aircraftId,allPastFlights[j].soldTickets, allPastFlights[j].captain, allPastFlights[j].copilot, allPastFlights[j].fsm, allPastFlights[j].fa1, allPastFlights[j].fa2) voyage.returnFlight = retFlight voyages.append(voyage) file1 = 'UpcomingFlights copy3.csv' return voyages
def employeeOccupied(employee, voyage): today = now() #Ef dagsetning flugferdar er staerri en nuverandi dagsetning er notad PastFlights copy, annars UpcomingFlights copy if today > voyage.departureFlight.departure: file = 'PastFlights copy.csv' else: file = 'UpcomingFlights copy3.csv' #Flug lesin inn ur theirri skra sem er valin flights = read_pastFlights(file) #Ar,manudur og dagsetningar settar i ser breytur voyYear = int(voyage.departureFlight.departure[0:4]) voyMonth = int(voyage.departureFlight.departure[5:7]) voyDay = int(voyage.departureFlight.departure[8:10]) #Fall sem breytir i isoformat voyDate = getDate(voyYear, voyMonth, voyDay, 0, 0) for flight in flights: #Farid i gegnum oll flug i flights: ar,manudur og dagsetningar settar i ser breytur flYear = int(flight.departure[0:4]) flMonth = int(flight.departure[5:7]) flDay = int(flight.departure[8:10]) #Fall sem breytir i isoformat flDate = getDate(flYear, flMonth, flDay, 0, 0) #Ef dagsetningarnar og starfsskodad hvort if voyDate == flDate: if employee.SSN == flight.captain: return True if employee.SSN == flight.copilot: return True if employee.SSN == flight.fsm: return True if employee.SSN == flight.fa1: return True if employee.SSN == flight.fa2: return True return False
def airplaneInUse(input_date, input_time): inptDay = str(input_date[0:2]) inptMonth = str(input_date[3:5]) inptYear = str(input_date[6:10]) stdInptDate = inptYear + '-' + inptMonth + '-' + inptDay + 'T' + input_time today=now() #fer inni viðeigandi skra if today>stdInptDate: file='PastFlights copy.csv' else: file='UpcomingFlights copy3.csv' allFlights=read_pastFlights(file) inAir=[] onGround=[] #tvær klst aftur i timann þvi ef flug tok af stað þa þa er það inAir timabil=add_hour(stdInptDate, (-2)) #fer gegnum öll flug og tekka hvort timasetningin og dags passi við for i in range(len(allFlights)): if inptDay == str(getDay(allFlights[i].departure)) and inptMonth == str(getMonth(allFlights[i].departure)) and inptYear == str(getYear(allFlights[i].departure)): #tekka hvort flugvel se i loftinu if timabil < allFlights[i].departure and allFlights[i].departure <= stdInptDate: air=createFlightRoute(allFlights[i].flightNumber, allFlights[i].departingFrom,allFlights[i].arrivingAt, allFlights[i].departure, allFlights[i].arrival, allFlights[i].aircraftId, allFlights[i].captain, allFlights[i].copilot, allFlights[i].fsm, allFlights[i].fa1, allFlights[i].fa2) inAir.append(air) else: onGr=createFlightRoute(allFlights[i].flightNumber, allFlights[i].departingFrom, allFlights[i].arrivingAt, allFlights[i].departure, allFlights[i].arrival, allFlights[i].aircraftId, allFlights[i].captain, allFlights[i].copilot, allFlights[i].fsm, allFlights[i].fa1, allFlights[i].fa2) onGround.append(onGr) #skila bæði flugvelum i lofti og þeim sem eru ekki return inAir, onGround
def voyageByDate(inptDate): #innslegin dagsetning fengin a staðlað format inptDay = str(inptDate[0:2]) inptMonth = str(inptDate[3:5]) inptYear = str(inptDate[6:10]) stdDate = inptYear + '-' + inptMonth + '-' + inptDay + 'T' + '00:00:00' #tekka hvaða skra eg vil fara inni today = now() if today > stdDate: file = 'PastFlights copy.csv' else: file = 'UpcomingFlights copy3.csv' allFlights = read_pastFlights(file) voyRet = [] voyDep = [] depDay = [] depMonth = [] depYear = [] depMinute = [] depHour = [] arrDay = [] arrMonth = [] arrYear = [] arrMinute = [] arrHour = [] tel = 0 for i in range(len(allFlights)): #til að geta fengið tima og dagsetningar a þægilegu formati depDay.append(str(getDay(allFlights[i].departure))) depMonth.append(str(getMonth(allFlights[i].departure))) depYear.append(str(getYear(allFlights[i].departure))) depMinute.append(str(getMinute(allFlights[i].departure))) depHour.append(str(getHour(allFlights[i].departure))) arrDay.append(str(getDay(allFlights[i].departure))) arrMonth.append(str(getMonth(allFlights[i].departure))) arrYear.append(str(getYear(allFlights[i].departure))) arrMinute.append(str(getMinute(allFlights[i].departure))) arrHour.append(str(getHour(allFlights[i].departure))) flugnr = allFlights[i].flightNumber no = int(flugnr[4:len(flugnr)]) #finn flug sem eru a innslegnum degi if stdDate[0:10] == allFlights[i].departure[0:10]: #dags og timas deptTime = depDay[tel] + '/' + depMonth[tel] + '/' + depYear[ tel] + ' at ' + depHour[tel] + ':' + depMinute[tel] arvlTime = arrDay[tel] + '/' + arrMonth[tel] + '/' + arrYear[ tel] + ' at ' + arrHour[tel] + ':' + arrMinute[tel] #tekka her hvort er utleið eða heimleið og by til viðeigandi klasatilvik if no % 2 == 0: voyD = createFlightRoute( allFlights[i].flightNumber, allFlights[i].departingFrom, allFlights[i].arrivingAt, allFlights[i].departure, allFlights[i].arrival, allFlights[i].aircraftId, allFlights[i].soldTickets, allFlights[i].captain, allFlights[i].copilot, allFlights[i].fsm, allFlights[i].fa1, allFlights[i].fa2) voyDep.append(voyD) elif no % 2 != 0: voyR = createFlightRoute( allFlights[i].flightNumber, allFlights[i].departingFrom, allFlights[i].arrivingAt, allFlights[i].departure, allFlights[i].arrival, allFlights[i].aircraftId, allFlights[i].soldTickets, allFlights[i].captain, allFlights[i].copilot, allFlights[i].fsm, allFlights[i].fa1, allFlights[i].fa2) voyRet.append(voyR) tel = tel + 1 #skila ut bæði utleiðum og heimleiðum sem passa við innslegna dagsetningu return voyDep, voyRet
def DLgetFlights(self): flights = read_pastFlights('UpcomingFlights copy3.csv') flights.extend(read_pastFlights('PastFlights copy.csv') ) #byr til lista med UpcomingFlights og PasFlights return flights
def emplWorking(inptDate): inptDay = str(inptDate[0:2]) inptMonth = str(inptDate[3:5]) inptYear = str(inptDate[6:10]) #set inslegna dagsetningu a isoformat 8601 standardDate = inptYear + '-' + inptMonth + '-' + inptDay + 'T' + '00:00:00' file2 = 'CrewCopy.csv' file = OpenFile(file2) allStaff = read_crew_file(file) #listi starfsmanna today = now() #opna pastflights ef innslegin dagsetning er minni en i dag en annars upcoming flights if today > standardDate: file1 = 'PastFlights copy.csv' else: file1 = 'UpcomingFlights copy3.csv' allPastFlights = read_pastFlights( file1) #öll flug úr þeirri skrá sem við á, klasatilvik #tómir listar til að nota updemplSSN = [] working = [] emplSSN = [] employees = [] noemployees = [] emplDest = [] emplLOKA = [] #fer í gegnum öll flugin for j in range(len(allPastFlights)): #sæki daginn hverju flugi day = str(getDay(allPastFlights[j].departure)) month = str(getMonth(allPastFlights[j].departure)) year = str(getYear(allPastFlights[j].departure)) #ef sami dagur og innsleginn set i listann emplSSN if inptDay == day and inptMonth == month and inptYear == year: emplSSN.append(allPastFlights[j].captain) emplSSN.append(allPastFlights[j].copilot) emplSSN.append(allPastFlights[j].fsm) emplSSN.append(allPastFlights[j].fa1) emplSSN.append(allPastFlights[j].fa2) #passa her að tvitelja ekki for i in emplSSN: if i not in updemplSSN: updemplSSN.append(i) #fer hér i gegnum alla starfsmenn og listann með kennitölum og athuga hvort eg finni sem passar og set þá í lista af starfsmannaklasatilvikum for j in range(len(allStaff)): for i in range(len(updemplSSN)): if allStaff[j].SSN == updemplSSN[i]: empl = createStaff(allStaff[j].name, allStaff[j].SSN, allStaff[j].address, allStaff[j].phoneNumber, allStaff[j].emailAddress, allStaff[j].rank, allStaff[j].role, allStaff[j].licence) employees.append(empl) #ef finn ekki þá set ég í starfsmannaklasatilvikslistan noemployees if allStaff[j].SSN not in updemplSSN: emp = createStaff(allStaff[j].name, allStaff[j].SSN, allStaff[j].address, allStaff[j].phoneNumber, allStaff[j].emailAddress, allStaff[j].rank, allStaff[j].role, allStaff[j].licence) noemployees.append(emp) #fer aftur í gegnum öll flug til að finna hvaða kennitala á við hvaða áfangastað for k in range(len(allPastFlights)): day = str(getDay(allPastFlights[k].departure)) month = str(getMonth(allPastFlights[k].departure)) year = str(getYear(allPastFlights[k].departure)) if inptDay == day and inptMonth == month and inptYear == year: for i in range(len(employees)): if employees[i].rank == 'Captain' and allPastFlights[ k].captain == employees[ i].SSN and allPastFlights[k].arrivingAt != 'KEF': emplDest.append(allPastFlights[k].arrivingAt + employees[i].SSN) elif employees[i].rank == 'Copilot' and allPastFlights[ k].copilot == employees[ i].SSN and allPastFlights[k].arrivingAt != 'KEF': emplDest.append(allPastFlights[k].arrivingAt + employees[i].SSN) elif employees[ i].rank == 'Flight Service Manager' and allPastFlights[ k].fsm == employees[i].SSN and allPastFlights[ k].arrivingAt != 'KEF': emplDest.append(allPastFlights[k].arrivingAt + employees[i].SSN) elif employees[i].rank == 'Flight Attendant' and ( allPastFlights[k].fa1 == employees[i].SSN or allPastFlights[k].fa2 == employees[i].SSN ) and allPastFlights[k].arrivingAt != 'KEF': emplDest.append(allPastFlights[k].arrivingAt + employees[i].SSN) #geri hér til að fá á þægilegt form for j in range(len(allStaff)): for i in range(len(emplDest)): if allStaff[j].SSN == str(emplDest[i][3:len(emplDest[i])]): emplLOKA.append(allStaff[j].name + ', ' + allStaff[j].role + ' - ' + str(emplDest[i][0:3])) #employees eru allir starfsmenn sem passa við input, noemployees eru allir starfsmenn sem passa ekki við input #emplLOKA er svo allir starfsmenn sem passa við input og afangastaðir þeirra return employees, noemployees, emplLOKA
def staffInfo2(input_string): skra1 = 'CrewCopy.csv' skra2 = 'PastFlights copy.csv' skra3 = 'UpcomingFlights copy3.csv' skra = OpenFile(skra1) allStaff = read_crew_file(skra) #listi allra starfsmanna employees = [] numOfupcDest = [] numOfpastDest = [] pastFlights = [] upcFlights = [] for i in range(len(allStaff)): #fer í gegnum alla starfsmenn ssn, rank = leitaStaff( input_string, allStaff ) #skilar listum af kennitölum og rank starfsm sem passa við input for j in range(len(ssn)): #fer i gegnum listann ssn if allStaff[i].SSN == ssn[ j]: #ber saman kennitölur ur báðum listum og by til kasatilvik af starfsmönnum sem passa við input empl = createStaff(allStaff[i].name, allStaff[i].SSN, allStaff[i].address, allStaff[i].phoneNumber, allStaff[i].emailAddress, allStaff[i].rank, allStaff[i].role, allStaff[i].licence) employees.append( empl ) #by til lista af öllum starfsmönnum sem passa við inputið break allUpcFlights = read_pastFlights(skra3) #öll upcomingflights #Upcoming flights for i in range( len(employees)): #fer í gegnum alla starfsmenn sem passa við input for j in range(len(allUpcFlights)): #í gegnum öll upcoming flights deptTime = str(getDay(allUpcFlights[j].departure)) + '/' + str( getMonth(allUpcFlights[j].departure)) + '/' + str( getYear(allUpcFlights[j].departure)) + ' at ' + str( getHour(allUpcFlights[j].departure)) + ':' + str( getMinute(allUpcFlights[j].departure)) arvlTime = str(getDay(allUpcFlights[j].arrival)) + '/' + str( getMonth(allUpcFlights[j].arrival)) + '/' + str( getYear(allUpcFlights[j].arrival)) + ' at ' + str( getHour(allUpcFlights[j].arrival)) + ':' + str( getMinute(allUpcFlights[j].arrival)) #fæ departure tima og arrival tima a akjosanlegu formati #ef rank starfsmans er flight attendant og eg finn hann a viðeigandi stað i upcoming flights þa buum við til #klasatilvik fluginu og set í upc flights. if employees[i].rank == 'Flight Attendant' and employees[ i].SSN in (allUpcFlights[j].fa1 or allUpcFlights[j].fa2): flight = createFlightRoute( allUpcFlights[j].flightNumber, allUpcFlights[j].departingFrom, allUpcFlights[j].arrivingAt, deptTime, arvlTime, allUpcFlights[j].aircraftId, allUpcFlights[j].soldTickets, allUpcFlights[j].captain, allUpcFlights[j].copilot, allUpcFlights[j].fsm, allUpcFlights[j].fa1, allUpcFlights[j].fa2) upcFlights.append(flight) #Geri nakvæmlega sama fyrir allt mögulegt rank starfsmanna elif employees[i].rank == 'Flight Service Manager' and employees[ i].SSN in allUpcFlights[j].fsm: flight = createFlightRoute( allUpcFlights[j].flightNumber, allUpcFlights[j].departingFrom, allUpcFlights[j].arrivingAt, deptTime, arvlTime, allUpcFlights[j].aircraftId, allUpcFlights[j].soldTickets, allUpcFlights[j].captain, allUpcFlights[j].copilot, allUpcFlights[j].fsm, allUpcFlights[j].fa1, allUpcFlights[j].fa2) upcFlights.append(flight) elif employees[i].rank == 'Captain' and employees[ i].SSN in allUpcFlights[j].captain: flight = createFlightRoute( allUpcFlights[j].flightNumber, allUpcFlights[j].departingFrom, allUpcFlights[j].arrivingAt, deptTime, arvlTime, allUpcFlights[j].aircraftId, allUpcFlights[j].soldTickets, allUpcFlights[j].captain, allUpcFlights[j].copilot, allUpcFlights[j].fsm, allUpcFlights[j].fa1, allUpcFlights[j].fa2) upcFlights.append(flight) elif employees[i].rank == 'Copilot' and employees[ i].SSN in allUpcFlights[j].copilot: flight = createFlightRoute( allUpcFlights[j].flightNumber, allUpcFlights[j].departingFrom, allUpcFlights[j].arrivingAt, deptTime, arvlTime, allUpcFlights[j].aircraftId, allUpcFlights[j].soldTickets, allUpcFlights[j].captain, allUpcFlights[j].copilot, allUpcFlights[j].fsm, allUpcFlights[j].fa1, allUpcFlights[j].fa2) upcFlights.append(flight) numOfupcDest.append(len(upcFlights)) allPastFlights = read_pastFlights(skra2) #Nakvæmlega sama gert fyrir past flights #Past flights for i in range(len(employees)): for j in range(len(allPastFlights)): deptTime = str(getDay(allPastFlights[j].departure)) + '/' + str( getMonth(allPastFlights[j].departure)) + '/' + str( getYear(allPastFlights[j].departure)) + ' at ' + str( getHour(allPastFlights[j].departure)) + ':' + str( getMinute(allPastFlights[j].departure)) arvlTime = str(getDay(allPastFlights[j].arrival)) + '/' + str( getMonth(allPastFlights[j].arrival)) + '/' + str( getYear(allPastFlights[j].arrival)) + ' at ' + str( getHour(allPastFlights[j].arrival)) + ':' + str( getMinute(allPastFlights[j].arrival)) if employees[i].rank == 'Flight Attendant' and employees[ i].SSN in (allPastFlights[j].fa1 or allPastFlights[j].fa2): flight = createFlightRoute( allPastFlights[j].flightNumber, allPastFlights[j].departingFrom, allPastFlights[j].arrivingAt, deptTime, arvlTime, allPastFlights[j].aircraftId, allPastFlights[j].soldTickets, allPastFlights[j].captain, allPastFlights[j].copilot, allPastFlights[j].fsm, allPastFlights[j].fa1, allPastFlights[j].fa2) pastFlights.append(flight) elif employees[i].rank == 'Flight Service Manager' and employees[ i].SSN in allPastFlights[j].fsm: flight = createFlightRoute( allPastFlights[j].flightNumber, allPastFlights[j].departingFrom, allPastFlights[j].arrivingAt, deptTime, arvlTime, allPastFlights[j].aircraftId, allPastFlights[j].soldTickets, allPastFlights[j].captain, allPastFlights[j].copilot, allPastFlights[j].fsm, allPastFlights[j].fa1, allPastFlights[j].fa2) pastFlights.append(flight) elif employees[i].rank == 'Captain' and employees[ i].SSN in allPastFlights[j].captain: flight = createFlightRoute( allPastFlights[j].flightNumber, allPastFlights[j].departingFrom, allPastFlights[j].arrivingAt, deptTime, arvlTime, allPastFlights[j].aircraftId, allPastFlights[j].soldTickets, allPastFlights[j].captain, allPastFlights[j].copilot, allPastFlights[j].fsm, allPastFlights[j].fa1, allPastFlights[j].fa2) pastFlights.append(flight) elif employees[i].rank == 'Copilot' and employees[ i].SSN in allPastFlights[j].copilot: flight = createFlightRoute( allPastFlights[j].flightNumber, allPastFlights[j].departingFrom, allPastFlights[j].arrivingAt, deptTime, arvlTime, allPastFlights[j].aircraftId, allPastFlights[j].soldTickets, allPastFlights[j].captain, allPastFlights[j].copilot, allPastFlights[j].fsm, allPastFlights[j].fa1, allPastFlights[j].fa2) pastFlights.append(flight) numOfpastDest.append(len(pastFlights)) return numOfpastDest, numOfupcDest, pastFlights, upcFlights, employees
def MostPopularDestination(): dest_arr = [] pastFlights_array = [] upcFlights_array = [] PopularDest = [] #path='/Users/SaraLind/github/verklegt_namskeid_1/csvFiles/' ########### open file 1 ########### skra1 = 'DestinationsCopy.csv' file1 = OpenFile(skra1) allDest = getDestinations() #by til lista af öllum destination sem eru ekki KEF for i in range(len(allDest)): if allDest[i].id != 'KEF': Destination = allDest[i].id dest_arr.append(Destination) length = len(dest_arr) ########### open file 2 ########### skra2 = 'PastFlights copy.csv' #file2 = OpenFile(skra2) allPastFlights = read_pastFlights(skra2) #by til lista af öllum destination ur pastflights for i in range(len(allPastFlights)): if allPastFlights[i].departingFrom == 'KEF': pastFlights = allPastFlights[i].arrivingAt pastFlights_array.append(pastFlights) ########### open file 3 ########### skra3 = 'UpcomingFlights copy3.csv' allUPcFlights = read_pastFlights(skra3) #by til lista af öllum destination ur upcomingflights for i in range(len(allUPcFlights)): if allUPcFlights[i].departingFrom == 'KEF': upcFlights = allUPcFlights[i].arrivingAt upcFlights_array.append(upcFlights) ########### Find the most popular destination ########### #set saman listana PopularDest = pastFlights_array + upcFlights_array counter = [] largest = 0 TheCounter = 0 count = 0 for i in range(length): counter.append(0) #fer gegnum allt til að finna hvaða afangastaður kemur oftast fyrir for i in range(length - 1): for j in range(len(PopularDest)): if dest_arr[i] == PopularDest[j]: counter[i] += 1 #Find the largest value for i in range(length - 1): if counter[i] > largest: largest = counter[i] #Find the location of biggest value for i in range(length - 1): if counter[i] == largest: count = TheCounter TheCounter += 1 #Find the most popular destination mostPopular = dest_arr[count] return mostPopular