Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. def nameMedals(last, first):
  2. gold = int('0')
  3. silver = int('0')
  4. bronze = int('0')
  5. lastflag = False
  6. firstflag = False
  7. flag = False
  8. with open("athletes.txt", encoding= 'utf-8') as file:
  9. for line in file:
  10. line = line.strip()
  11. if line == last.upper() or line == last.lower():
  12. lastflag = True
  13. elif line == first.upper() or line == last.lower():
  14. firstflag == True
  15. elif lastflag == True and firstflag == True:
  16. flag = True
  17. if line == '1':
  18. gold +=1
  19. elif line == '2':
  20. silver +=1
  21. elif line == '3':
  22. bronze +=1
  23. flag = False
  24. lastflag = False
  25. firstflag = False
  26. elif lastflag == False or firstflag == False:
  27. print("The name you specified is incorrect or is not in the data.")
  28. return
  29. return print(first + ' ' + last + ' won ' + str(gold) + ' gold medals, ' + str(silver) + ' silver medals, ' + str(bronze) + ' and bronze medals.')
  30.  
  31. def main():
  32. last = input('Enter the last name of an athlete: ')
  33. first = input('Enter the first name of the same said athlete: ')
  34. nameMedals(last, first)
  35.  
  36. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement