Python 29
[Python 100] Python 100
5
(Python2.x)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
x = int(raw_input(":\n"))
a = x / 10000
b = x % 10000 / 1000
c = x % 1000 / 100
d = x % 100 / 10
e = x % 10
if a != 0:
print "5 ",e,d,c,b,a
elif b != 0:
print "4 ",e,d,c,b,
elif c != 0:
print "3 ",e,d,c
elif d != 0:
print "2 ",e,d
else:
print "1 ",e
(Python3.x)
#!/usr/bin/python
x = int(input(":\n"))
a = x // 10000
b = x % 10000 // 1000
c = x % 1000 // 100
d = x % 100 // 10
e = x % 10
if a != 0:
print ("5 ",e,d,c,b,a)
elif b != 0:
print ("4 ",e,d,c,b)
elif c != 0:
print ("3 ",e,d,c)
elif d != 0:
print ("2 ",e,d)
else:
print ("1 ",e)
: 23459 5 9 5 4 3 2
: 3472 4 2 7 4 3
[Python 100] Python 100
126***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- print( '10:' ) n=input() x=[] i=0; while(n!=0): x.append(n%10) i+=1 n/=10 print( ' %d \n' %i ) print( '\n') print( x[::] )126***[email protected]
126***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- print '10' n=input() x=str(n) for i in range(len(x)-1,-1,-1): print x[i], # ,126***[email protected]
mythwind
774***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- print( '10:' ) a =input() if (len(str(a)) > 0) and (len(str(a)) <= 5) : print "%s %d " %(a, len(str(a))) newstr = str(a)[::-1] print newstr for i in newstr: print imythwind
774***[email protected]
mas***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- def output(num,l): if l == 0: return print (num[l-1]), output(num,l-1) num = raw_input('5 :' ) l = len(num) output(num,l) print '\n: %d' % lmas***[email protected]
252***[email protected]
Python3 reverse
#!/usr/bin/env python3 num = list(input('5:')) print(len(num)) num.reverse() for i in range(len(num)): print(num[i], end='')252***[email protected]
swordzjc
hfu***[email protected]
#!/usr/bin/python3 # coding:utf-8 s = str(input()) def fun(m): if len(m) == 1: return m[0] else: return (m[len(m) - 1] + fun(m[:(len(m) - 1)])) if len(s) > 5: print("") else: print('%s\n%s\n%s' % (len(s), s, fun(s)))swordzjc
hfu***[email protected]
py
928***[email protected]
#!/usr/bin/python # coding:utf-8 arr=[] def out_num(n): length = len(str(n)) print "%d"%length for i in range(1, length+1): arr.append((n % (10**i))/10**(i-1)) print arr out_num(245984)py
928***[email protected]
qingfeng
297***[email protected]
#!/usr/bin/env python # -*- coding: UTF-8 -*- import sys s = 12345 s = str(s)[::-1] print '%d ' % len(s) for i in range(len(s)): sys.stdout.write(s[i]+' ')qingfeng
297***[email protected]
253***[email protected]
Python3
# coding:utf-8 num=int(input(":")) 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() print("%d" % len(num)) print(":",fn(num)) break253***[email protected]
fish
353***[email protected]
:
#!/usr/bin/python # -*- coding: UTF-8 -*- def num(strl): l = len(str(strl)) lis = [] for i in range(l): x = strl % 10 strl /= 10 lis.append(x) print "{0}, \n:{1}".format(l,''.join(str(x) for x in lis) ) num(123)fish
353***[email protected]
colinshi
col***[email protected]
Python3
#!/usr/bin/python3 x=input(':\n') a = len(x) print('{}'.format(a)) b = -1 while a != 0: a -= 1 if b == -1: print(x[-1:],end=' ') b=b-1 else : print(x[b:b+1],end=' ') b=b-1colinshi
col***[email protected]
CosmosHua
cos***[email protected]
Python3
#!/usr/bin/python3 def backn(n): ls = str(n); s = len(ls) ls = ls[s-1:0:-1] + ls[0] return ls, s # backn(123456) #(['654321'], 6)CosmosHua
cos***[email protected]
yan***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- num1=int(input("Please input a int <10000:")) for i in range(4,1,-1): if num1>10**i: print(i+1) break list1=[] for j in range(i,-1,-1): list1.append(int(num1/(10**j))) num1=num1%(10**j) for k in range(i,-1,-1): print(list1[k])yan***[email protected]
qia***[email protected]
Python3
number = 12344 print("%d," % number, end="") n = 0 result = "" while number > 0: result += str(number % 10) number //= 10 n += 1 print("%d, : %d" % (n, int(result)))qia***[email protected]