title: AttributeError: 'tuple' object has no attribute 'write'
body: <p>I have a homework assignment for a Python class and am running into an error that I don't understand. Running Python IDLE v3.2.2 on Windows 7.</p>
  
  <p>Below is where the problem is happening:</p>
  
  <pre><code>#local variables
  number=0
  item=''
  cost=''
  
  #prompt user how many entries
  number=int(input('\nHow many items to add?: '))
  
  #open file
  openfile=('test.txt','w')
  
  #starts for loop to write new lines
  for count in range(1,number+1):
      print('\nFor item #',count,'.',sep='')
      item=input('Name:  ')
      cost=float(input('Cost: $'))
  
      #write to file
      openfile.write(item+'\n')
      openfile.write(cost+'\n')
  
  #Display message and closes file
  print('Records written to test.txt.',sep='')
  openfile.close
  </code></pre>
  
  <p>This is the error that I am getting:</p>
  
  <blockquote>
    <p>Traceback (most recent call last): File "I:\Cent 110\test.py", line 19, in openfile.write(item+'\n')<br>
    AttributeError: 'tuple' object has no attribute 'write'</p>
  </blockquote>