Update input_string to s for string examples

This commit is contained in:
Jared
2019-10-08 02:43:58 +00:00
parent 0f6556478c
commit e1c05cd1c1
11 changed files with 28 additions and 28 deletions

View File

@ -5,14 +5,14 @@ tags: string,intermediate
Returns `True` if the given string is a palindrome, `False` otherwise.
Use `input_string.lower()` and `re.sub()` to convert to lowercase and remove non-alphanumeric characters from the given string.
Use `s.lower()` and `re.sub()` to convert to lowercase and remove non-alphanumeric characters from the given string.
Then, compare the new string with its reverse.
```py
from re import sub
def palindrome(input_string):
s = sub('[\W_]', '', input_string.lower())
def palindrome(s):
s = sub('[\W_]', '', s.lower())
return s == s[::-1]
```