def is_palindrome(st): if len(st) < 1: return True else: if st[0] == st[-1]: return is_palindrome(st[1:-1]) else: return False str=str(input("Please enter string:")) if(is_palindrome(str)==True): print("Given string is palindrome") else: print("Given string is not palindrome") Output 1: Please enter string: did Given string is palindrome Output 2: Please enter string: done Given string is not palindrome
इन्हें भी देखें।
- while loop
- for loop
- nested loops
- loop control statements (Break, Continue, Pass)
- if statement
- if-else statement
- if-elif statement
- nested if statement
- range() function
- keywords
- Identifiers (names)
- Literals
- Operators
- punctuatorts
Python Programs के लिये यहाँ click करें।