Question: PYTHON ONLY! FOLLOW DIRECTIONS! Implement the function is_palindrome() in palindrome.py that returns True if the argument s is a palindrome (ie, reads the same forwards
PYTHON ONLY! FOLLOW DIRECTIONS!
Implement the function is_palindrome() in palindrome.py that returns True if the argument s is a palindrome (ie, reads the same forwards and backwards), and False otherwise. You may assume that s is all lower case and doesn't any whitespace characters. $ Python palindrome.py bolton False $ python palindrome.py amanaplanacanalpanama True import stdio import sys |# Return True if s is a palindrome and False otherwise. You may assume that # s is all lower case and doesn't any whitespace characters def is_palindrome (s): # Iterate over half of the string s. Compare character at i with # the character at len (s) - i - 1. If they are different, return False # Otherwise, continue. Return True when the loop is exhausted. for i in ...: # Test client [DO NOT EDIT]. Reads a string s as command-line argument and # prints True if s is a palindrome, ie, reads the same forwards and backwards, # and False otherwise. def_main(): s = sys.argv[1] stdio.writeIn(is_palindrome(s)) if_name_ == '_main_': _main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
