課程
/后端開發(fā)
/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:
if x<y:
print x * 10 + y
我的答案
優(yōu)化處理下,?不要判斷: 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程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2019-12-23
L = [1,2,3,4,5,6,7,8,9?]
for x in L:
for y in L:
if x<y:
print x * 10 + y
2020-02-01
我的答案
2020-01-31
2020-01-13
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)
為什么我這樣寫也能過?? print x+y? 輸出的到底是x與y的和還是簡單的拼接?
2020-01-04
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
2019-12-24
for x in [ 1,2,3,4,5,6,7,8,9 ]:
? ? for y in [ 1,2,3,4,5,6,7,8,9,0 ]:
? ? ? ? if x<y:
? ? ? ? ? ? ?print(10*x+y)