Discuss / Python / 两天作业一起交,请教下有没有更简洁的语句

两天作业一起交,请教下有没有更简洁的语句

Topic source

時安容

#1 Created at ... [Delete] [Delete and Lock User]

print ('\n作业1') #作业1

L = [ ['Apple', 'Google', 'Microsoft'], ['Java', 'Python', 'Ruby', 'PHP'], ['Adam', 'Bart', 'Lisa'] ] x = 0 y = 0 s = L[x] while y < len(L): while x < len(s): print ('\nHello,',L[y][x]) x += 1
else: y += 1 x = 0 else: print ('\nend')

print ('\n作业2') #作业2

L = [ ['Apple', 'Google', 'Microsoft'], ['Java', 'Python', 'Ruby', 'PHP'], ['Adam', 'Bart', 'Lisa'] ] x = 0 while x < len(L): for l in L[x]: print('\nHello,',l) else: x += 1 else: print ('\nend')

L=[['cisco','huawei','juniper','aruba'],['apple','samsung','sony'],['hp','ibm','dell'],['shanghai','beijing','guangzhou']]

for i in range(len(L)): for j in range(len(L[i])): print('hello','%s' % (L[i][j]))


  • 1

Reply