Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 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:
  12. lastflag = True
  13. elif line == first:
  14. firstflag == True
  15. elif lastflag == True and firstflag == True:
  16. flag = True
  17. # Added new elif statement here
  18. elif flag == True:
  19. if line == '1':
  20. gold +=1
  21. elif line == '2':
  22. silver +=1
  23. elif line == '3':
  24. bronze +=1
  25. # Moved them here
  26. flag = False
  27. lastflag = False
  28. firstflag = False
  29. else:
  30. print("The name you specified is incorrect or is not in the data.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement