title: using timeit functions with len functions in python
body: <p>I'm trying to calculate the program's runtime . How do I use timeit functions with len functions in this code.</p>
  
  <p>code:</p>
  
  <pre><code>import timeit
  def shellSort(alist):
      sublistcount = len(alist)//2
      while sublistcount &gt; 0:
  
        for startposition in range(sublistcount):
          gapInsertionSort(alist,startposition,sublistcount)
  
        print("After increments of size",sublistcount,"The list is",alist)
  
  
        sublistcount = sublistcount // 2
  
  def gapInsertionSort(alist,start,gap):
      for i in range(start+gap,len(alist),gap):
  
          currentvalue = alist[i]
          position = i
  
          while position&gt;=gap and alist[position-gap]&gt;currentvalue:
              alist[position]=alist[position-gap]
              position = position-gap
  
          alist[position]=currentvalue
      return alist
  alist = [54,26,93,17,77,31,44,55,20]
  shellSort(alist)
  print(alist)
  print(timeit.timeit("[len(alist)]","from__main__import shellSort"))
  </code></pre>
  
  <p>error given by the program:</p>
  
  <pre><code>After increments of size 4 The list is [20, 26, 44, 17, 54, 31, 93, 55, 77]
  
  After increments of size 2 The list is [20, 17, 44, 26, 54, 31, 77, 55, 93]
  
  After increments of size 1 The list is [17, 20, 26, 31, 44, 54, 55, 77, 93]
  
  [17, 20, 26, 31, 44, 54, 55, 77, 93]
  
  Traceback (most recent call last):
  
    File "C:/Users/Mervee/Desktop/shell sort.py", line 29, in &lt;module&gt;
  
      print(timeit.timeit("[len(alist)]","from__main__import shellSort"))
  
    File "C:\Python34\lib\timeit.py", line 213, in timeit
  
      return Timer(stmt, setup, timer).timeit(number)
  
    File "C:\Python34\lib\timeit.py", line 122, in __init__
  
      code = compile(src, dummy_src_name, "exec")
  
    File "&lt;timeit-src&gt;", line 3
  
      from__main__import shellSort
  
                                 ^
  SyntaxError: invalid syntax
  </code></pre>