Guest User

Untitled

a guest
Nov 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. from typing import List, Tuple, Dict, TextIO
  2. def names(file:TextIO) -> None:
  3. """ create a list with all the names from the file
  4. """
  5. lines = ""
  6. firstname = ""
  7. lastname = ""
  8. name_list = []
  9. file = open(file, 'r')
  10. for line in file:
  11. line = line.strip()
  12. lines += line
  13. for i in range(len(lines)):
  14. if lines[i] == ",":
  15. lastname += lines[i+2]
  16. first = i
  17. last = i + 3
  18. while lines[first].islower() and lines[last].islower():
  19. firstname += lines[first]
  20. lastname += lines[last]
  21. first -= 1
  22. last += 1
  23. name_list.append(firstname + " " + lastname)
Add Comment
Please, Sign In to add comment