- Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathq20.py
35 lines (30 loc) · 763 Bytes
/
q20.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
# Ask the user for a string and print out whether this string is
# a palindrome or not. (A palindrome is a string that reads the
# same forwards and backwards.)
mystring=input()
foriinrange(len(mystring) //2):
ifmystring[i] !=mystring[-1-i]:
print('Not Palindrome')
break
else:
print('Palindrome')
string="Hello"
i=0
forchinrange(len(string)):
if (string[i] !=string[-1-i]):
print('Not Palindrome')
break
else:
print("Pelindrom")
break
defreverse(word):
x=''
foriinrange(len(word)):
x+=word[len(word)-1-i]
returnx
word=input('give me a word:\n')
x=reverse(word)
ifx==word:
print('This is a Palindrome')
else:
print('This is NOT a Palindrome')