Question: I have a file containing:

```
name: James
player: 2

name: Martin
player: 3
.
.

```

where there is a space right after the ':' of name and player followed by a newline to another name and player.

I'm trying to access the James and 2, Martin and 3 without the 'name' and 'player'. I'm planning to use a counter for it which i tried:

```
filename = open("testing.txt","r", encoding = "utf-8")
playerFile = filename
lst = []
for line in playerFile:
    line = line.replace('\n','')  #replace newlines with an empty space
    lst.append(line)    #append into a lst for now

counter = 1    #initialize a counter
for i in range(len(lst)):
    if counter == 1:     #for name since name is on first line, hence take the string James
        ...              #how do i get just the string 'James'?
        counter +=1      #increment to go to line 2 which is the player
    elif counter == 2:    #for player
        ...
        counter +=1      #increment to go to line 3 which is a newline
    elif counter == 3:   #newline, empty, set back to 1
        counter = 1    #set back to one since the third line is empty

```

we can assume that the file will always have the format of 'name', followed by 'player' and followed by a 'newline' and followed by another 'name' and so on.

Answer: 
simple is better, why don't you iterate over the lines and check if it's `name` or `player` so will act accordingly, something like (draft)

```
for line in playerFile:
  attr = line.split()
  if atrr[0] == 'name:':
    # store name attr[1]
  elif attr[0] == 'player:':
    # store player attr[1]

```

NOTE: you need to handle blank lines and lines containing other text, and all scenarios in your input file...
```
playerFile = open("testing.txt","r", encoding = "utf-8")
lst = []
for line in playerFile:
  if line!='':
    lst.append(line)    #append into a lst for now

for sen in lst:
  words=sen.split()
  if words[0]=='name:':
    name=words[1]
  else:
    number=words[1]

```