idol
发表于 2018-3-20 10:04:37
def DealList(target_list):
done_list = []
temp = str(target_list[-1])[-1]
for i in range(len(target_list)-1):
temp1 = str(target_list[-1-i])[:-1]
temp2 = str(target_list[-1-i-1])[-1]
target_list[-1-i] = int(temp2 + temp1)
done_list.append(target_list[-1-i])
done_list.append(int(temp+str(target_list)))
done_list.reverse()
#print(done_list)
return done_list
list1 =
DealList(list1)
LargeCat
发表于 2018-3-20 10:24:38
def Convert(alist):
m=''
for i in alist:
m+=str(i)
n=+m)]
for i in range(len(m)-1):
n.append(int(m))
return n
a=
print(Convert(a))
答案:
luokaoge
发表于 2018-3-20 10:47:09
def re(s):#输入一个列表,例如s =
#打印输入参数
print(s)
s1 = []
s2 = []
#获取输入列表的长度,并分离列表中单个元素
l = len(s)
for i in range(0,l):
a = str(s)
t = len(a)
#将分离的元素重组列表
for i in range(0,t):
b = a
s1.append(b)
#将最后的元素移到最前
d = s1
s1.insert(0,d)
del s1
#重组两位数新列表,针对元素个数奇偶分开处理
if len(s1)%2 == 0 :
for i in range(0,len(s1),2):
#删除0开头的两位数
if int(s1) == 0:
a = s1
else:
a = s1 + s1
s2.append(int(a))
else:
for i in range(0,len(s1)-1,2):
if int(s1) == 0:
a = s1
else:
a = s1 + s1
s2.append(int(a))
#元素个数位奇数时,单独添加最后一个元素
s2.append(int(s1))
return(s2)
a = re()
print(a)
运行结果:
grf1973
发表于 2018-3-20 11:23:47
def fun(mlist):
mstr=''.join()
mstr=mstr[-1]+mstr
mlist=) for k in range(0,len(mlist))]
return mlist
mlist=
print('转换前:',mlist)
print('转换后:',fun(mlist))
JessiFly
发表于 2018-3-20 11:40:08
def my_change(old):
temp = [] #存储原列表中每个两位数拆分成的两个数
new = []
for each in old:
a = each//10
b = each%10
temp.append(a)
temp.append(b)
length = len(temp)
for i in range(length-1):
if i%2 != 0:
new.append(temp*10 + temp)
new.insert(0,temp[-1]*10 + temp)
return new
old_list =
print(my_change(old_list))
大头目
发表于 2018-3-20 12:28:18
def Lshift(list1):
list2 = []
ax = 0
for i in range(len(list1)):
if i == 0:
ax = (list1[-1]%10)*10 + list1//10
else:
ax = (list1%10)*10 + list1//10
list2.append(ax)
return list2
list1 =
print('input:',list1)
print('output:',Lshift(list1))
grf1973
发表于 2018-3-20 13:08:32
考虑到位数不定def fun(mlist):
mstr=list(','.join())
for k in range(0,len(mstr)):
if mstr==',':
mstr,mstr=mstr,mstr
mstr=''.join(mstr)
mstr=mstr[-1]+mstr
mlist=
return mlist
mlist=
print('转换前:',mlist)
print('转换后:',fun(mlist))
jiamin_2010
发表于 2018-3-20 13:41:02
def list1():
l =[]#生成列表
while True:
s =input("enter a num:")
if s == "0":
break
else:
l.append(s)
bs =" "#转换字符串
for i in l:
bs +=i+""
bs=bs[-1]+bs[:-1]#换位子
bs_1 =bs.replace(" ","") #去空格
bs_lst = []
i=0
while i < len(str(bs_1)):
bs_lst.append(bs_1)
i=i+2
return bs_lst #生成新列表
n = list1()
print(n)
{:10_266:}含泪做出来 新手 感觉自己逻辑思维太差劲
凹凸曼呵呵哒
发表于 2018-3-20 13:49:14
#参数temp为一个两位数组成的列表
def func(temp):
index = []#最终需返回的列表
#将数组转化为字符串
chars = ''
for i in temp:
chars += str(i)
chars = chars[-1] + chars#利用切片将字符串最后一个字符修改到第一
for i in range(0, len(chars), 2):
index.append(int(chars))
return index
qpwoeiruty
发表于 2018-3-20 13:52:22
def yiwei(x):
z=list(x)
l = len(z)
new = []
i = 0
while i <l:
new.append((z//10)+(z%10)*10)
i = i+1
return new
y= tuple(eval(input ('请输入一个都是由两位数组成的列表')))
print(yiwei(y))
Chase_Kas
发表于 2018-3-20 14:25:47
本帖最后由 Chase_Kas 于 2018-3-20 14:26 编辑
def fun(mylist):
allnum, result = '', []
for each in mylist:
allnum += str(each)
lenth = len(allnum)
allnum = allnum + allnum
for i in range(0, lenth, 2):
result.append(int(allnum))
return result
print(fun())
jiantu
发表于 2018-3-20 15:24:35
def day167(l):
cond = 0
if isinstance(l,list) == 0:
print('您输入的不是列表')
else:
for i in l:
if i//10 > 10 or i//10 < 1:
print('您输入的不是两位数列表')
break
else:
cond =1
if cond:
count = 0
l1 = //10]
while count < len(l)-2:
l1.append(l%10*10+l//10)
count += 1
l1.append(l[-2]%10*100+l[-1])
l1 = l1[-1]%10*10 + l1
l1[-1] =l1[-1]//10
return l1
else:
None
nanayuri
发表于 2018-3-20 16:18:21
def new_lis(*args):
str1 = ''
new_list = []
count_list = []
for each in args:
count_list.append(len(str(each)))
str1 += str(each)
print(len(str1))
i = count_list - 1
c_list = count_list
print(i)
for each in c_list:
num = int(str1)
new_list.append(num)
i += each
while i >= len(str1):
break
new_list.insert(0, int(str1[-1] + str1 - 1]))
return new_list
o41003121
发表于 2018-3-20 16:47:30
def switchnl(nlist):
nlength = len(nlist)
nclist = []
for each in range(nlength):
nclist.append(nlist%10*10+nlist//10)
return nclist
nlist =
print(switchnl(nlist))
夜与晨
发表于 2018-3-20 16:48:59
def output(list_origin):
str_oringin = ''.join()
list_temp =
list_temp.insert(0,list_temp.pop())
list_ans = for i in range(0, len(list_temp), 2)]]
return list_ans
if __name__ == "__main__":
list_origin =
print(output(list_origin))
o41003121
发表于 2018-3-20 17:05:40
def switchnl(nlist):
nlength = len(nlist)
nclist = []
for each in range(nlength):
nump = len(str(nlist))
nclist.append(nlist%10*(10**(nump-1))+nlist//10)
return nclist
nlist =
print(switchnl(nlist))
实现多位数的移动
lcfyujianwen
发表于 2018-3-20 17:19:23
def yiwei(a):
s = ''
for i in range(len(a)):
s += str(a)
c = []
for i in range(len(s)):
if i%2 ==0:
if i == 0:
c.append(int(s+s))
else:
if s == '0':
c.append(int(s))
else:
c.append(int(s))
return c
if __name__ == '__main__':
e =
print(yiwei(e))
输出:
太笨的办法,只能解答应付两位数列表,还要看看各位的解答,增长知识
_小菜鸟
发表于 2018-3-20 17:44:25
#-*- coding:utf8 -*-
def fun(lis):
str1,new = "",""
li3 = []
for j in range(len(lis)):
str1 += str(lis)
str2 = str1 + str1
for i in range(len(str2)):
if i%2==0 :
new += str2
elif i==0:
new += str2
elif i==len(str2)-1:
new += str2
else:
new += str2+ ","
li2 = new.split(",")
for i in range(len(li2)):
li3.append(int(li2))
return li3
if __name__ == '__main__':
li =
result = fun(li)
print(result)
测试结果:
ouyunfu
发表于 2018-3-20 17:58:13
list1 =
list2 = []
list3 = []
for i in range(len(list1)):
if i==0:
list2.append(list1//10)
elif i == len(list1)-1:
list2.append(list1 % 10 * 100 + list1)
else:
list2.append(list1%10*10+list1//10)
for i in range(len(list2)):
if i==0:
list3.append(list2[-1]%10*10+list2)
elif i==len(list2)-1:
list3.append(list2[-1]//10)
else:
list3.append(list2)
print(list3)
阿bang
发表于 2018-3-20 18:01:37
def change(numlist):
newlist = []
newlist.append(numlist / 10)
for i in range(1, len(numlist) -1 ):
numcount = 0 #计算索引为2后面的数字原本的位数
temp = numlist
while temp:
numcount += 1
temp /= 10
newlist.append(numlist % 10 * pow(10, (numcount - 1))+ numlist / 10) #逗号左移,计算左移后的数字
numcount = 0
temp = numlist[-1]
while temp:
numcount += 1
temp /= 10
newlist.append(numlist[-2] % 10 * pow(10, numcount) + numlist[-1])
numcount = 0
temp = numlist
while temp:
numcount += 1
temp /= 10
newlist += newlist[-1] % 10 * pow(10, numcount - 1)
newlist[-1] = newlist[-1] / 10
return newlist
print change()
重写了一个支持任意位数的