Update reverse string challenge (#113)

Update input check logic to check for an empty but not None entry.
This commit is contained in:
Donne Martin 2016-11-06 08:38:08 -05:00 committed by GitHub
parent aa4c8ae5b4
commit c6677586d3

View File

@ -97,8 +97,8 @@
"class ReverseString(object):\n",
"\n",
" def reverse(self, chars):\n",
" if chars is None:\n",
" return None\n",
" if chars is None or not chars:\n",
" return chars\n",
" size = len(chars)\n",
" for i in range(size//2):\n",
" chars[i], chars[size-1-i] = \\\n",
@ -126,13 +126,13 @@
"class ReverseStringAlt(object):\n",
"\n",
" def reverse_string_alt(string):\n",
" if string is None:\n",
" return None\n",
" if string is None or not string:\n",
" return string\n",
" return string[::-1]\n",
"\n",
" def reverse_string_alt2(string):\n",
" if string is None:\n",
" return None\n",
" if string is None or not string:\n",
" return string\n",
" return ''.join(reversed(string))"
]
},