课程
/后端开发
/Python
/初识Python
for x in [ 1,2,3,4,5,6,7,8,9 ]:
for y in [ 2,3,4,5,6,7,8,9 ]:
if x<y:
print x*10+y
2019-12-23
源自:初识Python 5-8
正在回答
L = [1,2,3,4,5,6,7,8,9 ]
for x in L:
for y in L:
print x * 10 + y
我的答案
优化处理下, 不要判断: for x in range(1,10): for y in range(x+1,10): print x*10+y
for x in [ '1','2','3', '4','5','6','7','8','9']:
for y in [ '0','1','2','3', '4','5','6','7','8','9' ]:
print (x+y)
为什么我这样写也能过? print x+y 输出的到底是x与y的和还是简单的拼接?
慕妹2214238
为何_
for x in [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]: for y in [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]: if x < y: print x, y
for y in [ 1,2,3,4,5,6,7,8,9,0 ]:
print(10*x+y)
举报
学python入门视频教程,让你快速入门并能编写简单的Python程序