Exercise 2 solution : Python tutorial 78

preview_player
Показать описание
Guys please help this channel to reach 20,000 subscribers. I'll keep uploading quality content for you.

Python is easy programming language to learn and anyone can learn it, and these tutorials are 100% free in hindi.

You can share this playlist with your brother, sisters and friends. This will surely add some values to their life.

If you follow this complete playlist of python tutorial surely you will learn everything about python programming language.

This is solution of exercise 2

Рекомендации по теме
Комментарии
Автор

i think this is the best solution
def ispalindrome(a):
if a[0:]==a[-1::-1]:
return print("true")
return print("false")
a=input("enter the string")
ispalindrome(a)

CodeClock
Автор

def palindrome(txt):
return txt == txt[-1::-1]
print(palindrome(input("Enter text: ")))

nehalzaman
Автор

SIR HARSHIT OF THANKS ADN RESPECT FROM PAKISTAN

MrZeekkhan
Автор

Achieved it in a different way: :D In your assignment forgot word[::-1] so create my own logic to reverse
def is_palendrom(word):
length = len(word)
length = length + 1
i = 0
j = 0
inputValue = ""
while i < length:
if i == 0:
j = -1
else:
j = -i
inputValue += word[j]
i = i + 1
print ("inputValue rotated", inputValue)
if word == inputValue:
return True
else:
return False

print ("Is Pelandrom : ", is_palendrom('madam'))


it works :) but your code is simple i think i followed the KISS logic :D

mubbashar
Автор

i solved like this -

#python 3.7.1

def p(x):
if x[-1].lower()== x[0].lower():
print(" true ")
else:
print(" false ")

y = input("")
print(p(y))

prem_patel
Автор

name = input("enter your name ")
pname = name[::-1]
if name == pname:
print("True")
else:
print("False")

rawquesh
Автор

def is_palindrom(a):
if a[::-1] == a:
return "It is a palindrom"
return "Not a palindrom"

word = input("Enter a word to check for palidrome : ")
print(is_palindrom(word))

GamingwithMooon
Автор

name = input('enter a name:')

def palindrome(name):


if name == name[::-1]:
return True
else:
return False

print(palindrome(name))

MrNile
Автор

cant thank you enough for this amazing code

junaidjaved
Автор

def is_palindrome(a):
if a == a[::-1]:
return True
else:
return False

shivam_shahi
Автор

def palindrome (name):
If name[-1]==name[0]:
return True
return False
Name=Input("enter your name")
Print(palindrome (name))

bhushanghate
Автор

name = input('Enter a name : ')
name = name.lower()
def is_palindrome(a):
if a == a[::-1]:
return True
else:
return False
print(is_palindrome(name))

SohailMughal
Автор

def palin(a):
b=len(a)
if a==a[::-1]:
return True
return False


a=input("enter string:")
print(palin(a))

shashankkumar
Автор

def Pali(name):
if name[::-1]==name:
return "Palindrome"
return "Not Palindrome"

name=input("Enter name : ")
print(Pali(name))

dr.immpetus
Автор

My solution -
def is_palindrome(string):
string1=string.lower()
length=len(string1)
string_rev=string1[::-1]
for i in range(length):
if string1[i]==string_rev[i]:
return True
else:
return False
string=input("Enter any string: ")
print(f"The input string is palindrome : {is_palindrome(string)}")

shishirkatiyar
Автор

I implemented it using a different logic. Compared the extremities of the given word to check if the are the same alphabet using for loop and stored the results, which I later checked if any of the result was not palindrome.


def palindrome_check(word):
heap = ""
for i in range(0, len(word)):
if word[i] == word[(len(word)-1-i)]:
heap += "palindome"
else:
heap += "NotPalindrome"
if 'NotPalindrome' in heap:
print("The given word is not palindome")
else:
print("The given word is palindrome")

palindrome_check("abcba")

dheeraj
Автор

string = input("Enter any word: ")
a =string[::-1]
if a == string:
print("same")
print("not")
#maine aisa banaya tha...

prateikjindal
Автор

def palindrom (words):
if words == words[::-1]:
return True
words =input("enter words : ")
print(palindrom(words))

RashidAli-covt
Автор

def is_palindrome(a):
if a[0] and a[-1] ==a[0] and a[-1]:
return True
else:
return False

a=input("Enter Your Name : ")
print(is_palindrome(a))

xNnja
Автор

Sir,
Maine aapne se different string bnai h.. But usme
User se input lekar output me show ho jayega ki wo palindrome word h ya nhi.. Jo mene method use kiya h kya wo shi h..

RajGupta-pgcx
join shbcf.ru