Skip to content

Commit d5a8098

Browse files
committed
doc: add comments
Loop structure: for. Palindrome detector.
1 parent b70a861 commit d5a8098

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

ex053.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#53- Create a program that reads any sentence and says if it is a palindrome, disregarding spaces. Examples of
2-
# palindromes:
3-
# AFTER THE SOUP, THE BALCONY OF THE HOUSE, THE TOWER OF DEFEAT, THE WOLF LOVES THE CAKE, THEY WROTE DOWN THE DATE
4-
# OF THE MARATHON.
1+
#Palindrome Detector
2+
#53- Create a program that reads any sentence and says if it is a palindrome, disregarding spaces.
53
sentence = str(input('Enter a sentence:')).strip().upper()
64
words = sentence.split()
75
together = ''.join(words)
@@ -13,3 +11,22 @@
1311
print('We have a palindrome.')
1412
else:
1513
print('The sentence is not a palindrome.')
14+
15+
16+
#Detector de Palíndromo
17+
#53: Crie um programa que leia uma frase qualquer e diga se ela é um palíndromo, desconsiderando os espaços. Exemplos
18+
# de palíndromos:APÓS A SOPA, A SACADA DA CASA, A TORRE DA DERROTA, O LOBO AMA O BOLO, ANOTARAM A DATA DA MARATONA.
19+
frase = str(input('Digite uma frase:')).strip().upper()
20+
palavras = frase.split()
21+
junto = ''.join(palavras)
22+
inverso = ''
23+
for palavras in range(len(junto)-1,-1,-1):
24+
inverso += junto[palavras]
25+
if inverso == junto:
26+
print('Nós temos um palíndromo.')
27+
else:
28+
print('Nós não temos um palíndromo.')
29+
30+
31+
#PT- Estruturas de repetições: For.
32+
#EN- Loop structures: For.

0 commit comments

Comments
 (0)