title: multiply a matrix by an integer in python
body: <p>I know how to multiply two matrices(under a class). Below I show my code. However I can not seem to figure out how to multiply a matrix and an integer in Python.</p>
  
  <p><strong>Update</strong>:
  Example of a matrix.</p>
  
  <pre><code>L=[[1,2],[3,4],[5,6]]
  3*L
  # [[1,6],[9,12],[15,18]]
  
  def __mul__(self,other):
      '''this will multiply two predefined matrices where the number of
      columns in the first is equal to the number of rows in the second.'''
      L=self.L
      L2=other.L
      result=[]
      if len(L[0])==len(L2):
          for i in range(len(L)):
              row=[]
              for j in range(len(L2[0])):
                  var=0 
                  for k in range(len(L2)):
                      var=var+L[i][k]*L2[k][j]
                  row=row+[var]
              result = result+[row]
          return matrix(result)
      else:
          raise ValueError('You may not only multiply m*n * n*q matrices.')
  </code></pre>