Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. def player(details) :
  2. details = details.split()
  3. (team, position, name, lname, salary) = details
  4. return (team, position, name, lname, salary)
  5.  
  6. def playerdetails(details) :
  7. details = details.split()
  8. (team, position, name, lname, salary) = details
  9. print ("{:>12}".format(lname) + (",{:>10s}".format(name)) + (",{:>11s}".format(salary)) + (",{:>10s}".format(position)) + (",{0:>10s}".format(team)))
  10.  
  11.  
  12. inFile = input("Input file name: ")
  13. data = []
  14. try:
  15. fIn = open(inFile, 'r')
  16. except IOError as e :
  17. fIn = None
  18. print("Failed to open", inFile,"- program aborted")
  19. if fIn != None :
  20. for line in fIn:
  21. data.append(tuple(line.split()))
  22. fIn.close()
  23.  
  24.  
  25. def datatable():
  26. print(": Last Name : First Name : Salary : Position : Team :")
  27. for item in data:
  28. print(":{:^15s}:".format(item[3]), ("{:^15s}:".format(item[2])),("{:^11s}:".format(item[4])),\
  29. ("{:^13s}:".format(item[1])), ("{:^9s}:".format(item[0])))
  30.  
  31. while True:
  32. print(" ")
  33. print("More Details")
  34. print("Input a team to display details")
  35. print("Or exit search with 'Quit'")
  36. i = input(":")
  37. if i == item[0]: # You're gonna need to search the data list here to find the team you can't do it in the same loop you're building the table with
  38. print((item[2]), (item[3]))
  39. break
  40. if i == "quit":
  41. print("Search has been quit")
  42. break
  43.  
  44.  
  45.  
  46. datatable()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement