Check if a String is Palindrome or Not in Python | EP-24 Python Program to Check Palindrome

Subscribers:
27,900
Published on ● Video Link: https://www.youtube.com/watch?v=K6NLxLywdfU



Duration: 0:00
123 views
0


method 1:

Reverse the string using slicing
String = input("enter the string")
print(String)
revered_string =String[::-1]
print(revered_string,"rev")
if(revered_string == String):
print("palindrome")
else:
print("not palindrome")

method2:

Check String is Palindrome using one extra variable
"""
In this method, the user takes a character of string one by one and store it in an
empty variable. After storing all the characters user will compare both the string and
check whether it is palindrome or not."""


x = input("enter the string"):

Prompts the user to enter a string and stores it in the variable x.
print(x):

Prints the entered string to the console.
w = " ":

Initializes an empty string and assigns it to the variable w. This variable will be used to store the reversed string.
for i in x::

Starts a for loop that iterates through each character i in the input string x.
w = i + w:

Appends the current character i to the beginning of the w string. This effectively reverses the characters of the input string.
if(w==i)::

Check if the reversed string w is equal to the current character i. This is incorrect logic when checking a palindrome.
print("palindrome"):

Prints "palindrome" if the incorrect condition in the previous line is true.
else::

If the condition is false (which it always will be), execute the following block.
print("not palindrome"):

Prints "not palindrome" if the condition is false.

#python #programming #tutorial #palindrome #coding #pythonprogramming #pythoncode #pythontutorial #learnpython #codingtutorial #datascience #algorithms #datastructures #beginner #intermediate #codingchallenge #pythonchallenge #PythonTutorial #PalindromeChecker #PythonBeginners #TechEducation




Other Videos By Cybrosys Technologies


2024-08-12New Employee Login Screen in Odoo 18 POS | Odoo 18 Point of Sale | Odoo 18 New Features | Odoo 18
2024-08-11Bank Account Menu in Odoo 18 Employee App | Odoo 18 New Features | Latest Features in Odoo 18
2024-08-11How to Create Worksheet Template in Odoo 17 Field Service | Customize Worksheet in Odoo 17
2024-08-08How to Capitalize Each String in a List of Strings in Python | EP-26 String Capitalize() Method
2024-08-08How to Hide Seconds From Date Time Fields in Odoo 18 | Odoo 18 New Features |Odoo 18 Latest Features
2024-08-07How to Create Timesheets Report Using Odoo 17| Timesheet Reports in Odoo 17| Odoo 17 Tutorials
2024-08-07How to Apply Within Operator in Custom Filter in Odoo 18| Within Operator in Odoo 18 Domain Selector
2024-08-06How to Create Separate Skill Zones in Recruitment Software | Skill Zone Management in Horilla HRMS
2024-08-06How to Remove a Character From a String in Python | EP-25 How to Remove Letters From a String
2024-08-06Quick Login Option to Land in Odoo 18 | Odoo 18 New Features | Odoo 18 Latest Features | Odoo 18
2024-08-05Check if a String is Palindrome or Not in Python | EP-24 Python Program to Check Palindrome
2024-08-04What is Escape Sequence in Python | EP-23 Escape Sequence in Python | Escape Characters in Python
2024-08-04Select Product Variant Pop Up In Odoo 18 Point Of Sale | Odoo 18 POS | New Features in Odoo 18
2024-08-04How to Manage Approval in Odoo 17 | How to Create Approval in Odoo 17 | Odoo 17 Functional Tutorials
2024-08-01What is String in Python | EP-22 String in Python | How to Manage String Data Type |Python Tutorials
2024-08-01What is PLM Reporting (ECO) in Odoo 17 | Reporting Section of Odoo 17 PLM |Engineering Change Orders
2024-08-01Passkey Authentication in Odoo 18 | Auth Passkey in Odoo 18 | How to Configure Passkey in Odoo 18
2024-07-31How to Manage Open Jobs as well as Application Form in Recruitment Software for Free | Horilla HRMS
2024-07-31How to Configure Product Category in Odoo 17 |Product Category Management in Odoo 17 |Odoo 17 Videos
2024-07-31How to Manage User Sessions, Devices In Odoo 18 |Session Management in Odoo 18 |Odoo 18 New Features
2024-07-30Under Warranty in Odoo 18 Field Service | Odoo 18 Field Service Management | Odoo 18 New Features