Odpowiedź:
#6.2
#a
text = input("Podaj tekst\n")
for c in text:
print(c, end =' ')
print('\n')
#b v1
for i in range(0, len(text)):
print(text[len(text) - i - 1], end = ' ')
#b v2
print(text[::-1])
#c
if(i % 2 == 0 and i != 0):
print(' ', end = '')
print(text[i], end = '')
#d
if(i % 3 == 0 and i != 0):
print(text[len(text) - i - 1], end = '')
#6.7
reversed = text[::-1]
if(reversed == text):
print("Palindrom")
else:
print("Nie palindrom")
Wyjaśnienie:
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
Odpowiedź:
#6.2
#a
text = input("Podaj tekst\n")
for c in text:
print(c, end =' ')
print('\n')
#b v1
for i in range(0, len(text)):
print(text[len(text) - i - 1], end = ' ')
#b v2
print(text[::-1])
#c
for i in range(0, len(text)):
if(i % 2 == 0 and i != 0):
print(' ', end = '')
print(text[i], end = '')
#d
for i in range(0, len(text)):
if(i % 3 == 0 and i != 0):
print(' ', end = '')
print(text[len(text) - i - 1], end = '')
#6.7
reversed = text[::-1]
if(reversed == text):
print("Palindrom")
else:
print("Nie palindrom")
Wyjaśnienie: