KangarooOnIce

animals test

Jul 29th, 2022
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. begin_with_a = []
  2. six_letters_long = []
  3. path_to_animals = 'animals.txt'
  4.  
  5.  
  6. with open(path_to_animals, 'r') as f:
  7.     for line in f.readlines():
  8.         if line.startswith('A'):
  9.             begin_with_a.append(line)
  10.  
  11. with open(path_to_animals, 'r') as f:
  12.     for line in f.readlines():
  13.         if len(line) == 7:
  14.             six_letters_long.append(line)
  15.  
  16. for i in begin_with_a:
  17.     print(i)
  18.  
  19.  
  20. for i in six_letters_long:
  21.     print(i)
Advertisement
Add Comment
Please, Sign In to add comment