Fixed Python2 vs Python3 division compatibility.

This commit is contained in:
Donne Martin
2015-07-06 07:06:50 -04:00
parent 53f7c0e4d8
commit 5338e59a43

View File

@@ -33,7 +33,6 @@
"source": [ "source": [
"## Constraints\n", "## Constraints\n",
"\n", "\n",
"* Is a single character or number a palindrome?\n", "* Is a single character or number a palindrome?\n",
" * No\n", " * No\n",
"* Can we assume we already have a linked list class that can be used for this problem?\n", "* Can we assume we already have a linked list class that can be used for this problem?\n",
@@ -100,6 +99,9 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"from __future__ import division\n",
"\n",
"\n",
"class MyLinkedList(LinkedList):\n", "class MyLinkedList(LinkedList):\n",
" \n", " \n",
" def is_palindrome(self):\n", " def is_palindrome(self):\n",
@@ -117,7 +119,7 @@
" \n", " \n",
" # Compare the reversed list with the original list\n", " # Compare the reversed list with the original list\n",
" # Only need to compare the first half \n", " # Only need to compare the first half \n",
" iterations_to_compare_half = length / 2\n", " iterations_to_compare_half = length // 2\n",
" curr = self.head\n", " curr = self.head\n",
" curr_reversed = reversed_list.head\n", " curr_reversed = reversed_list.head\n",
" for _ in range(0, iterations_to_compare_half):\n", " for _ in range(0, iterations_to_compare_half):\n",