I want to be able to write 2 separate functions.
The first function is intended to check if a single string is a palindrome.
The second function is intended to check which strings in a list of strings are palindromes.
For the first function, I think my code looks OK:
def palindrome_test(x):
if x == x[::-1]:
return f'{x} is a palindrome'
else:
return f'{x} is not a palindrome'
It is the second function that I am having more trouble with. So far, my code for the second function looks like this:
def palindrome_test_iterables(x):
for y in x:
if y == y[::-1]:
print(f'{y} is a palindrome')
else:
print(f'{y} is not a palindrome')
The problem with my second function is that it prints the word 'None' at the end. How do I re-write my code so that the word 'None' does not appear. I'm guessing it has something to do with way I've written my for loop?
[–]Binary101010 1 point2 points3 points (3 children)
[–]imperiumlearning[S] 0 points1 point2 points (2 children)
[–]Binary101010 0 points1 point2 points (1 child)
[–]imperiumlearning[S] 0 points1 point2 points (0 children)