Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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

palindrome string python

a=input('enter a string :')# palindrome in string
b=a[::-1]
if a==b:
    
 print(a,'is a palindrome')
else:
 print(a,'is not a palindrome')
 print('a is not equal to b')
 if a!=b:
   print(b, 'the reverse of', a)
#output:
--------------------------------------------------------------------------------
case-I
# not palindrome
enter a string :1254
1254 is not a palindrome
a is not equal to b
4521 the reverse of 1254
--------------------------------------------------------------------------------
case-II
# palindrme
enter a string :12321
12321 is a palindrome
Comment

Palindrome in Python Using while loop for string

def check_palindrome(string):
    length = len(string)
    first = 0
    last = length -1 
    status = 1
    while(first<last):
           if(string[first]==string[last]):
               first=first+1
               last=last-1
           else:
               status = 0
               break
    return int(status)  
string = input("Enter the string: ")
status= check_palindrome(string)
if(status):
    print("It is a palindrome ")
else:
    print("Sorry! Try again")
Comment

PREVIOUS NEXT
Code Example
Python :: pypdf2 advanced tutorial 
Python :: how to sort values in python 
Python :: how to open annaconda 
Python :: true and false in python 
Python :: maximum subarray sum 
Python :: insert-cells-in-empty-pandas-dataframe 
Python :: find item in list 
Python :: pip install 
Python :: geckodriver seleniunm setup 
Python :: pahtlib join path 
Python :: ner spacy 
Python :: python conditionals 
Python :: how to add hyperlink in jupyter notebook 
Python :: tkinter transparent background 
Python :: how to add array and array python 
Python :: scrape website with login python selenium 
Python :: Broadcasting with NumPy Arrays Two dimension array dimension array Example 
Python :: Renaming and replacing the column variable name 
Python :: how to make a stopwatch in pythoon 
Python :: find location of max value in python list 
Python :: .replace python 
Python :: typeerror: 
Python :: how to perform group by with django orm 
Python :: how to specify symbol in matplotlib 
Python :: python with braces 
Python :: print specific key in dictionary python 
Python :: how to run python code in python 
Python :: app.py 
Python :: qr code detector 
Python :: py quick sort 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =