-
Notifications
You must be signed in to change notification settings - Fork 0
/
palindrome.py
74 lines (61 loc) · 1.11 KB
/
palindrome.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# def ifPalindrome(string):
# if string == "": # BASE CASE CONDITION
# return True
# elif len(string) == 1: # BASE CASE CONDITION
# return True
# elif string[0] == string[len(string)-1]: # RECURSION
# return ifPalindrome(string[1:][:-1])
# else:
# return False
# a=ifPalindrome("nitin")
# print(a)
# name=['n','i','t','i','n']
# i=0
# b=''
# a=''
# while i<len(name):
# b+=name[i]
# i=i+1
# i=1
# while i<=len(name):
# a+=name[-i]
# i=i+1
# print(a)
# if b==a:
# print(a,"palindrome")
# else:
# print("not palindrome")
a=["nitin","tanu","12321"]
i=0
while i<len(a):
j=0
b=''
c=''
while j<len(a[i]):
b+=a[i][j]
j+=1
# print(b)
j=1
while j<=len(a[i]):
c+=a[i][-j]
j+=1
# print(c)
i+=1
if b==c:
print(b,"palindrome")
else:
print(b,"not")
def fa(a):
if a==1:
return 1
return a*fa(a-1)
print(fa(5))
def pal(a):
b=a[::-1]
v=a
if b==v:
return 'PAL'
else:
return 'NOT'
u=input("enter the:-")
print(pal(u))