Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python palindrome string

s = "001100"

if s == s[::-1]:
    print("palindrome string")
else:
    print("Not a palindrome string.")
Comment

Palindrome Check using for loop in python

p = list(input())
for i in range(len(p)):
    if p[i] == p[len(p)-1-i]:
        continue
    else:
         print("NOT PALINDROME")
         break
else:
    print("PALINDROME")
Comment

How to check for palindromes in python

def is_palindrome(s):
  reverse = s[::-1]
  if (s == reverse):
    return True
  return False

s1 = 'racecar'
s2 = 'hippopotamus'

print(''racecar' a palindrome -> {}'.format(is_palindrome(s1)))
print(''hippopotamus' a palindrome -> {}'.format(is_palindrome(s2)))


# output

# 'racecar' is a palindrome -> True
# 'hippopotamus' is a palindrome -> False
Comment

Python - How To Check if a String Is a Palindrome

word = input() if str(word) == str(word)[::-1] :     print("Palindrome") else:     print("Not Palindrome")
Comment

How to check if a given string is a palindrome, in Python?

"""
This implementation checks whether a given
string is a palindrome. A string is 
considered to be a palindrome if it reads the
same forward and backward. For example, "kayak"
is a palindrome, while, "door" is not. 

Let n be the length of the string

Time complexity: O(n), 
Space complexity: O(1)
"""
def isPalindrome(string):
    # Maintain left and right pointers
    leftIdx = 0
    rightIdx = len(string)-1
    while leftIdx < rightIdx:
        # If chars on either end don't match
        # string cannot be a palindrome
        if string[leftIdx] != string[rightIdx]:
            return False
        # Otherwise, proceed to next chars
        leftIdx += 1
        rightIdx -= 1
    return True

print(isPalindrome("kayak"))  # True
print(isPalindrome("door"))  # False
Comment

how to check a string is palindrome or not in python

s = "001100"

if s == s[::-1]:
    print(s, "is a Palindrome string.")
else:
    print("Not a palindrome string.")

    
Comment

How to check palindrom in python

myString = "aba"
if myString == myString[::-1]:
	print("The string '" + myString + "' is a palindrome")
else:
	print("The string '" + myString + "' is not a palindrome")
Comment

check palindrome in python

string = input("Type a string: ")
if string[::-1] == string: 
	print(string,"This string is Palindrome")
else:
	print(string,"This string is not Palindrome")
Comment

python palindrome check

#Palindrome check
word = 'reviver'
p = bool(word.find(word[::-1]) + 1)
print(p) # True
Comment

palindrome words python

mes=input("Enter the word and see if it is palindrome ")
if mes==mes[::-1]:
    print("This word is palindrome")
else:
    print("This word is not palindrome")
Comment

PREVIOUS NEXT
Code Example
Python :: python convert a dict to list or a list to dict or a slice a dict or sort a dict by key or value without import 
Python :: TypeError at /admin/auth/user/ 
Python :: import turtle python 
Python :: go to python 
Python :: difference between methods and attributes 
Python :: PEP 428: The pathlib module – object-oriented filesystem paths. 
Python :: no module named cbor2 windows 
Python :: pie auto percentage in python 
Python :: df.sample(frac=1) 
Python :: how to change speed in ursina 
Python :: example python 
Python :: discord.py find user by name 
Python :: list into string python 
Python :: pe039 
Python :: how to write a table from 1 to 10 with for loop in fython in 3 lines 
Python :: repeat every entru n times 
Python :: COMBINE TWO 2-D NUMPY ARRAYS WITH NP.VSTACK 
Python :: convertir code python en java 
Python :: how to convert comma separated string to list in python 
Python :: how to add 2 integers in python 
Python :: sample one point from distribution python 
Python :: compute slice distance from image position 
Python :: locate certs path for python 
Python :: Get timestamp with pyrhon 
Python :: flask new response style with `make_response` 
Python :: get the value of qpushbutton pyqt5 with argument 
Python :: python debugger online 
Python :: matplotlib set dpi 300 
Python :: Cget subassembly civid3d 
Python :: find no of iterations in python 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =