title: How to iterate through characters and lines in Python?
body: <p>Let's say I have a file containing this: </p>
  
  <pre><code>xxoxoxoxox
  
  xxxxxxxxxx
  
  xoxoxoxoxo
  
  ooxoxoxoxo
  </code></pre>
  
  <p>and I want to iterate through each character and line and store them.</p>
  
  <p>I know that if the characters are separated by spaces, I can do this:</p>
  
  <pre><code>mylist=[]    
  with open("myfile.txt") as myfile:    
      for line in file:    
          line = line.strip().split(" ")    
          first = line[0]    
          second = line[1]    
          alist = [first, second]    
          mylist.append(alist)
  </code></pre>
  
  <p>But how do I do something like this without spaces as delimiters? I tried <code>.split()</code>
  and</p>
  
  <pre><code>for line in file:    
     for char in line:
  </code></pre>
  
  <p>But neither seems to work.</p>
  
  <p>Thanks in advance for any help!</p>