Advertisement
MORGATRON16

Untitled

Sep 8th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 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.    
  15.   return routesList  
  16.  
  17. while True:
  18.   try:
  19.     n = input ("How many routes can have an extra bus? ")
  20.     n = int (n)    
  21.   except ValueError:
  22.       print ("Invalid value. Please enter a non-negative integer")
  23.       continue
  24.   if n < 0:
  25.       print("Invalid value. Please enter a non-negative integer")
  26.       continue
  27.   else:
  28.     break
  29. route = read_route_data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement