Answer:
<em>This program is written in python programming language</em>
<em>The program uses few comments (See Explanation for further explanation of each line)</em>
<em>See attachment for proper format view of the source code</em>
<em>Program starts here</em>
<em></em>
#Prompt user for Input
inpstring = input("Enter a string: ")
#Reverse user input
revstring = inpstring[::-1]
#Calculate length of user input
i = len(inpstring)
if(inpstring.upper() == revstring.upper()):
print("The input string is Palindrome")
else:
if(inpstring[0].upper() == inpstring[i-1].upper()):
print("The input string is a Special Word")
else:
print("The input string is neither Palindrome nor Special")
Explanation:
inpstring = input("Enter a string: ")-> This line accepts input from user
revstring = inpstring[::-1]-> This line reverses user input
i = len(inpstring)-> This line calculates the length of user input
The following if statement checks for palindromes; i.e. if input string is equal to reversed string
if(inpstring.upper() == revstring.upper()):
print("The input string is Palindrome")
If the above is statement is not true, the following is executed (to check for special word)
else:
The following if statement checks if the first letter of the input string is equal to its last letter
if(inpstring[0].upper() == inpstring[i-1].upper()):
print("The input string is a Special Word")
If the above statement if not true, then input string is not a special word and it's not palindromic.
Hence, the its accompanying else statement will be executed
else:
print("The input string is neither Palindrome nor Special")