Python 30
[Python 100] Python 100
512321
(Python 2.0+)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
a = int(raw_input(":\n"))
x = str(a)
flag = True
for i in range(len(x)/2):
if x[i] != x[-i - 1]:
flag = False
break
if flag:
print "%d !" % a
else:
print "%d !" % a
(Python 3.0+)
#!/usr/bin/python3
a = int(input(":\n"))
x = str(a)
flag = True
for i in range(len(x)//2):
if x[i] != x[-i - 1]:
flag = False
break
if flag:
print ("%d !" % a)
else:
print ("%d !" % a)
: 12321 12321 !
[Python 100] Python 100
13121
107***[email protected]
Python3.x
#!/usr/bin/env python3 a = input(": ") b = a[::-1] if a == b: print("%s "% a) else: print("%s "% a)13121
107***[email protected]
252***[email protected]
Python3
#!/usr/bin/env python3 str = input("5: ") if str[0] == str[-1] and str[1] == str[-2]: print( "%s !" % str) else: print( "%s !" % str)252***[email protected]
sunjl
136***[email protected]
python312321123321
def number30(): n = input("please input a num:") x = list(n) l = len(x) if l % 2 != 0: # mediant = int((l + 1)/2) # i = x[:mediant - 1] x.reverse() j = x[:mediant - 1] if i == j: print("{0}".format(n)) else: print("{0}".format(n)) else: mediant = int(l / 2) i = x[:mediant] x.reverse() j = x[:mediant] if i == j: print("{0}".format(n)) else: print("{0}".format(n)) number30()sunjl
136***[email protected]
253***[email protected]
Python3 :
# coding:utf-8 num=int(input("5:")) def fn(s): if len(s)==1: return(s[0]) else: a=s[-1] s=s[:-1] return(a+fn(s)) while 1: if num<=0 or len(str(num))!=5: num=int(input(":")) else: num=str(num) print() if fn(num)==num: print("%s" % num) else: print("%s" % num) break253***[email protected]
Mervyn
110***[email protected]
# coding:utf-8 def is_true_num(num): if 10000<=num and num <=99999: b = num/10000 c = (num/1000)%10 d = (num%1000)%100/10 e = num%10 if b==e and c==d: print "%d"%num else: print "%d"%num else: print "%d" % num if __name__ == '__main__': a = int(raw_input("5")) is_true_num(a)Mervyn
110***[email protected]
643***[email protected]
# coding:utf-8 def test(num): if(num>=10000 and num<100000): s=str(num) x=[] for i in s: x.append(i) if(x[0]==x[4] and x[1]==x[3]): print "" else: print "" else: print "" test(12321)643***[email protected]
Leo
wl4***[email protected]
Python3
# s=input('Pleae enter 5 numbers:>>>') li1=[] li2=[] for i in s: li1.append(i) li2.append(i) li2.reverse() print(li1,li2) if li1== li2: print('Yes') else: print('No')Leo
wl4***[email protected]
382***[email protected]
Python3
#!/usr/bin/env python3 a = input("") b=list(a) m=1 for i in range(len(a)//2): if a[i]!=a[-1-i]: print("") m=0 break if m: print("")382***[email protected]
129***[email protected]
# -*- coding:utf-8 -*- # Python3 x = int(input(':\n')) a = x // 10000 b = x % 10000 // 1000 c = x % 1000 // 100 d = x % 100 // 10 e = x % 10 if a == e and b == d: print('%d',x) else: print('%d',x)129***[email protected]