1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vinil7 [7]
3 years ago
9

Write a program palindrome.py that prompts for a sequence of words or numbers on a single line and checks if the entries are pal

indromes or not. A word or a number is a palindrome if it remains unchanged when reversed. e.g. rotor is a palindrome; but python is not a palindrome. e.g. 737 is a palindrome; but 110 is not a palindrome. The program receives the sequence as input and returns True if an entry is a palindrome or False if an entry is not a palindrome. Print the boolean value on one line. Print the palindromes count on the next line.
Computers and Technology
1 answer:
olya-2409 [2.1K]3 years ago
3 0

Answer:

Explanation:

The program first asks the user for the sequence of words. Then it splits the sequence into an array of words. Then it loops through the array checking each word to see if it is a palindrome. If it is it prints the word, the boolean value, and adds 1 to the palindrome_count variable. Otherwise it prints the word, false, and moves on to the next word in the list. Finally, it prints out the total value of palindrome_count.

word = input("Enter sequence of words: ")

word_list = word.split(' ')

print(word_list)

palindrome_count = 0

for word in word_list:

   print('\n\n')

   reverse = word[::-1]

   if word == reverse:

       print(word, end='\n')

       print(True, end="\n")

       palindrome_count += 1

   else:

       print(word, end='\n')

       print(False, end='\n')

print("\n\nNumber of Palindromes in Sequence: " + str(palindrome_count))

You might be interested in
What are village by laws​
melomori [17]

Explanation:

LAWS have long been familiar to the student of the English village. these regulations dealt mai ly with the open-field husbandry and pasture rights of ....

4 0
3 years ago
In what ways do cameras allow us to see the world in ways that we could not with only our eyes?
Grace [21]
Cams always us to see things that happen when we are not there
6 0
3 years ago
Read 2 more answers
What effect on total current flow will a shorted series component have in a series-parallel circuit?
Citrus2011 [14]
Im going to go with D on this one but dont rely on my answer this is just a  educated guess

7 0
3 years ago
6. You should check your tire pressure
tatyana61 [14]
Answer

Once every week

3 0
3 years ago
Where is the worlds biggest cookie​
rjkz [21]

I believe the cookie monster has it

3 0
3 years ago
Read 2 more answers
Other questions:
  • D-H public key exchange Please calculate the key for both Alice and Bob.
    12·1 answer
  • The ________ of the operating system enables the user to communicate with the computer system. Select one:
    9·1 answer
  • What is an abstract class? (Points : 2) A generalized class used only to create related derived classes
    6·1 answer
  • "Inheritance is the process by which a new class - known as a _________ - is created from another class, called the ____________
    11·1 answer
  • A filter is limited to extracting data from a single table. <br> a. True <br> b. False
    9·1 answer
  • Hydraulic pressure is the same throughout the inside of a set of brake lines. What determines the amount of resulting mechanical
    7·1 answer
  • How does using wind energy relate to our world today?
    8·2 answers
  • Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
    7·1 answer
  • To have a set of command
    6·1 answer
  • CSCU EXAM TEST FINAL1-A software or hardware that checks information coming from the Internet and depending on the applied confi
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!