title: I am trying to extract data from excel sheet with and without def statement (functions) in python
body: <p>I have recently started learning PYTHON and I am facing some difficulty.</p>
  <p>I am trying to extract data from excel sheet  with and without def statement . So without def, I am getting valid output but when I extract data using def statement, I am getting &quot;NONE&quot; as output. Please help me to resolve this.</p>
  <pre><code>book=xlrd.open_workbook(&quot;E:\\Email.xlsx&quot;)
  
  print(book.nsheets)
  
  SheetName =book.sheet_by_name(&quot;gmail&quot;)
  
  rows=SheetName.nrows
  
  cols=SheetName.ncols
  
  print(rows)
  
  print(cols)
  </code></pre>
  <p><strong>##### WITHOUT DEFINING ANY FUNCTION ####</strong></p>
  <pre><code>table=list()
  
  record=list()
  
  for x in range(rows):
  
      for y in range(cols):
  
          record.append(SheetName.cell(x,y).value) 
  
          table.append(record)
  
          record=[]
  
          rows=rows+1
  
  print(table)
  </code></pre>
  <blockquote>
  <p>O/P:[['Email ID:'], ['AVVC.com'], ['Password'], ['abcdefg']]</p>
  </blockquote>
  <strong>WITH DEF</strong>
  <pre><code>def getcell(rows,cols):
  
  table=list()
  
  record=list()
  
  
  for x in range(rows):
  
      for y in range(cols):
  
          record.append(SheetName.cell(x,y).value) 
  
          table.append(record)
  
          record=[]
  
          rows=rows+1
  
          return;
  
  v= getcell(0,1)
  
  print(v)
  </code></pre>
  <p>O/P:NONE</p>