     "source": [
      "def insertion_sort(data):\n",
      "    if len(data) < 2:\n",
      "        return\n",
      "    for r in xrange(1, len(data)):\n",
      "        for l in xrange(0, r):\n",
      "            if data[l] > data[r]:\n",
      "                temp = data[r]\n",
      "                data[l+1:r+1] = data[l:r]\n",
      "                data[l] = temp\n",
      "                break"
 
</s> remove     "    for l in xrange(lower, upper + 1):\n",
    "        for u in xrange(lower, upper + 1):\n",
 </s> add     "    for l in range(lower, upper + 1):\n",
    "        for u in range(lower, upper + 1):\n", </s> remove     "    for i in xrange(start + 1, len(data)):\n",
 </s> add     "    for i in range(start + 1, len(data)):\n", </s> remove     "    for i in xrange(0, len(data)):\n",
 </s> add     "    for i in range(0, len(data)):\n", </s> remove     "    for i in xrange(0, len(data) - 1):\n",
 </s> add     "    for i in range(0, len(data) - 1):\n", </s> remove     "    for i in xrange(1, cycles+1):\n",
 </s> add     "    for i in range(1, cycles+1):\n",
    "    for r in range(1, len(data)):\n",
    "        for l in range(0, r):\n",
     "source": [
      "def insertion_sort(data):\n",
      "    if len(data) < 2:\n",
      "        return\n",
    "    for r in range(1, len(data)):\n",
    "        for l in range(0, r):\n",
    "    for r in range(1, len(data)):\n",
    "        for l in range(0, r):\n",
      "            if data[l] > data[r]:\n",
      "                temp = data[r]\n",
      "                data[l+1:r+1] = data[l:r]\n",
      "                data[l] = temp\n",
      "                break"
keep keep keep keep replace replace keep keep keep keep keep
 Changed xrange to range to be compatible with Python 3. 
sorting_searching/insertion_sort/insertion_sort_solution.ipynb