write an algorithm and draw a corresponding flowchart to test whether a given word is a palindrome.
Answers
Answered by
2
Code in Python 3.x:
str = input()
if str == str[::-1]:
print(str, "is a palindrome.")
else:
print(str, "is not a palindrome")
Explanation:
First line: asks for an input string.
Second line onwards: checks if the original string is the same as the reverse of the string. If true, then it prints that the string is a palindrome. if false, it prints that the string is not a palindrome.
Flow chart:
Sorry because I wasn't able to type in paint. I have colored them for your understanding.
Blue: Start
Green: Input
Purple: Check if string is palindrome
Orange: Yes, print it is.
Yellow: No, print it isn't.
Brown: End
Attachments:
Similar questions