Question

Python coding

Palindromic Cargo

The Gocargo carriers are celebrating their digitization process, which has given them a lot of benefits and ease of work for their employees. In account of this initiative they are offering their customers to ship their cargoes free of cost, if and only if the cargo names are palindromic.


Given a cargo name, check whether the cargo name is a palindrome or not. Consider only alphabets while checking, remove special characters and spaces.


Note : Define a function named check Palindrome() with a string argument.


Input Format :

Input consists of a string, the cargo’s name. Input is case - insensitive.


Output Format:

Output is a string which contains “Yes” or “No”.


Sample Input 1:

!!Race !Car!!

Sample Output 1:

Yes


Sample Input 2:

Racer Car

Sample Output 2:

No


Explanation For Sample 1:

Cargo name: !!Race !Car!!

After removing special characters and spaces, the name is "RaceCar".

Now, making the string case-insensitive, it becomes "racecar", which is a palindrome.


0 0
Add a comment Improve this question Transcribed image text
Answer #1

message=input()

#!!Race !Car!!


m=""

for i in range(0,len(message),1):

    if((message[i]>='A' and message[i]<='Z') or (message[i]>='a' and message[i]<='z')):

        m=m+message[i]




def checkPalindrome(message):

    word=message[::-1]

    if(word==message):

        return "Yes"

    else:

        return "No"



print(checkPalindrome(m.lower()))


answered by: Satyam Keshri
Add a comment
Know the answer?
Add Answer to:
Python coding
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Coding

    The Cargo arrangementThe Gocargo carriers have a pattern of arranging the cargos in the container. Given the length of edge of the container, print the cargo arrangement pattern in the container as shown in the sample IO. The base of the container is always a square.Note: The Cargo are of unit length.Input format :     The input is an integer that corresponds to the side length of the container.Output Format:     Output is the cargo arrangement pattern inside the container.Please refer to the sample...

  • Solve by using Python language Validation of Invoice Number The Gocargo carriers are extending their automation...

    Solve by using Python language Validation of Invoice Number The Gocargo carriers are extending their automation to their accounts wing too, It is difficult to identify the source and destination of a cargo in an invoice. So given an invoice number, determine the "from" and "to" for a cargo. The format of invoice number is as follows: * from-Country and to-Country are separated by few digits(atleast 1) * after to-Country there are few digits. Input Format :       Input consists...

  • Python coding

    The Weight Detection SensorThe Gocargo carriers has planned to automate the filling of cargos in the container. They have installed a weight detection sensor in the conveyor belt where cargos will be taken to the container. The sensor needs to be programmed in a way that it stops the conveyor sending the cargos, when the maximum capacity of the container is reached or exceeded.Please write a code to enable the sensor to automate this task of finding the number of...

  • PLEASE USE MATLAB This is a basic problem that illustrates the concept of strings. A palidrome...

    PLEASE USE MATLAB This is a basic problem that illustrates the concept of strings. A palidrome is a string of characters that is read the same forwards as it is backwards. For example, racecar' is a palindrome; reversing the order of the characters leaves the string unchanged. Write a otherwise. function called isPalindrome that accepts one input and returns one output. The input str is a string of characters, and the output is 1 if str is a palindrome, For...

  • Palindrome Detector C++ A palindrome is any word, phrase, or sentence that reads the same forward...

    Palindrome Detector C++ A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able was I, ere I saw Elba A man, a plan, a canal, Panama Desserts, I stressed Kayak Write a program that determine whether an input string is a palindrome or not. Input: The program should prompt the user "Please enter a string to test for palindrome or type QUIT to exit: " and then wait for...

  • Palindrome is a word or a phrase when taken in reverse order, gives the same word...

    Palindrome is a word or a phrase when taken in reverse order, gives the same word or phrase. For example, the word “radar” is a palindrome. The phrase "Do geese see God?" is also a palindrome after the removal of the question mark and all the spaces and the conversion of the remaining alphabets to either upper or lower case. Write a program that uses an STL stack to check if an arbitrary string containing multiple words separated by spaces...

  • A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here...

    A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able was I, ere I saw Elba A man, a plan, a canal, Panama Desserts, I stressed Kayak Write a program that determine whether an input string is a palindrome or not. Input: The program should prompt the user "Please enter a string to test for palindrome or type QUIT to exit: " and then wait for the user input....

  • Python coding

    The Gocargo are automating their testing works of the logistics wing too. They have planned to test if the container loading works correctly or not.Given the process involved in loading, in the form of expression, evaluate if the container loader has worked correct or not.Conventions'{' for cargos, '[' for containers and '(' for boxes.Rules:* cargo cannot be inside another cargo or container or box.* container cannot be inside another container or box.* box can be inside another box.Please check whether...

  • Python Coding

    Expiry DateAt Transglobal Logistics, a commodity will be accepted for shipment only if it reaches the destination before the expiry date. Find whether a commodity is accepted for shipping, based on the expiry date, departure date of the commodity from the Source port and number of days required to reach the destination port.Input Format:First line is a string that corresponds to the expiry date.Second line is a string that corresponds to the departure date of the commodity from the source...

  • PLEASE WRITE SIMPLE JAVA PROGRAM AND ALSO EXPLAIN THE LOGIC. Given a string, print the first...

    PLEASE WRITE SIMPLE JAVA PROGRAM AND ALSO EXPLAIN THE LOGIC. Given a string, print the first word which has its reverse word further ahead in the string. Input Format: A string of space separated words, ending with a 's'. Conditions ; Each string ends with a $ character. All characters in the string are either spaces. $ or lower case English alphabets, Output Format : In a single line pent either . The first word from the start of the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT