开发者

check whether the sting is palindrome or not? [duplicate]

开发者 https://www.devze.com 2022-12-07 18:57 出处:网络
This question already has answers here: How to check for palindrome using Python logic (35 answers) Reverse a string in Python
This question already has answers here: How to check for palindrome using Python logic (35 answers) Reverse a string in Python (18 answers) Closed 3 hours ago. 开发者_如何学编程

if yes then print the string is palindrome

code using if else and basic python

Input : malayalam Output : Yes

Input : geeks Output : No


def isPalindrome(s): return s == s[::-1]

s = "malayalam" ans = is Palindrome(s)

if ans: print("Yes this is a palindrome") else: print("No")

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号