Не получается одновременно удалить все символы из текста + пробелы, и нужно, чтобы регистр букв автоматом менялся на нижний.
import string abc = string.ascii_lowercase symb = string.punctuation #Переменные со всеми буквами нижнего регистра #И вторая - со всеми символами def is_palindrome(text): return text == text[::-1] something = input("Type some text ") s1="".join(c for c in something if c.isalpha()) #Попытался сделать таким методом, но оно не пашет. #Его можно убрать, чтобы код работал if is_palindrome(something): print("There is a palindrome") else: print("There isn't a palindrome")
Задача состоит в том, чтобы проверить слово, является ли оно палиндромом(читается ли одинаково справа-налево и наоборот, как слово "потоп"). Задача в том, чтобы при проверке убирались пробелы и любые символы, а также регистр букв весь менялся на нижний. Для того, чтобы палиндромом могли считатся и такие штуки, как "Приве т, тевирп"(Не обращает внимание на пробелы, знаки и регистр). Буду благодарен за помощь. Полагаю, что может помочь метод string.replace() , но я не совсем понял, как и уместен ли он здесь.

We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.Fornex
Let me recommend you a great European Fornex hosting.
Fornex has proven itself to be a stable host over the years.
For Django projects I recommend VPS hosting
Following the link you will receive a 5% discount on shared hosting services, dedicated servers, VPS and VPN
View HostingShare on social networks
Donate
The EVILEG project has switched to a non-commercial basis and will develop solely on the enthusiasm of the site creator, the enthusiasm of users, donations and the hosting referral system
Thank you for your support
Available ways to support the project
PayPal
PatreonYandex.MoneyMore