I can test whether a user supplied string is a palindrome or not (word or phrase that can be read backwards ignoring spaces and uppercase and lowercase letters, for example: Help me get on the bus in Morocco), using the code:
string = raw_input()
stringSemEspacos = string.replace(' ', '')
stringTodaMinuscula = stringSemEspacos.lower()
stringInvertida = stringTodaMinuscula[::-1]
if stringInvertida == stringTodaMinuscula:
print "SIM"
else:
print "NAO
I need to write a program that, before receiving the strings to be tested, first receives an integer, which corresponds to the number of strings that must be tested. If you want to test 4 strings, the number 4 must be the first entry in the program, followed by the 4 strings that will be tested, and the program must judge each string and print the 4 answers, between Yes and No. How to do it receive the amount of strings established, make the judgment and only then be terminated?
How do I do:
i = 0
quantidade = int(raw_input())
while i < quantidade:
i += 1
string = raw_input()
stringSemEspacos = string.replace(' ', '')
stringTodaMinuscula = stringSemEspacos.lower()
stringInvertida = stringTodaMinuscula[::-1]
if stringInvertida == stringTodaMinuscula:
print "SIM"
else:
print "NAO"