Advertisement
MORGATRON16

Untitled

Sep 9th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. def read_route_data():
  4.   routesList = []
  5.   with open("routes.txt", "rt") as in_file:
  6.     routes = in_file.read()
  7.   tempList = routes.split(',')
  8.   i = 0
  9.   while i < tempList.len:
  10.     x = tempList[i]
  11.     i = i + 1
  12.     y = tempList[i]
  13.     routesList.append({'route_number': x, 'happy_ratio': y})
  14.   return routesList
  15.  
  16. def sort_route_data(routesList):
  17.   currentLowest = 0
  18.   for i in routesList.len:
  19.     for j in routesList.len:
  20.       if (i == j):
  21.         print ("do nothing")
  22.         continue
  23.       if (routesList[j] < currentLowest dict ["happy_ratio"]):
  24.         currentLowest = routesList[j] dict ["route_number"]
  25.         routesList.append currentLowest
  26.         currentLowest = routesList[i]
  27.         return routesList[i]
  28.         continue
  29.       else:
  30.         break
  31.  
  32. while True:
  33.   try:
  34.     n = input ("How many routes can have an extra bus? ")
  35.     n = int (n)    
  36.   except ValueError:
  37.       print ("Invalid value. Please enter a non-negative integer")
  38.       continue
  39.   if n < 0:
  40.       print("Invalid value. Please enter a non-negative integer")
  41.       continue
  42.   else:
  43.     break
  44. route = read_route_data  
  45.  
  46. print(routes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement