二维列表和索引

时间:2017-10-03 03:08:32

标签: python

写一个函数passenger_baggage(),它有两个参数:p和b,其中p是乘客编号,b是行李编号。在您的函数中,将以下2-D列表分配给变量:

def passenger_baggage(p,b):
    'Where p is the passenger number and b is the number'
    m = [[ 45,35,52,75],[25,30,65], [50,43,32,22,]]

    for i in range (p[]b[])
    print ('bag #{} , for passenger number #{} weighs lb'.format(b,p))

矩阵或2-D列表m显示三名乘客的行李重量(磅)。第一位乘客有4个行李,第二位乘客有3个行李,第三位乘客有4个行李。

您的函数将使用在演讲期间讨论的行和列索引来显示乘客信息,如示例所示,使用format()字符串方法

我有这个:

Sub InsertPageNumberForEndnotes()
Dim endNoteCount As Integer
Dim curPageNumber As Integer
If ActiveDocument.Endnotes.Count > 0 Then
  For endNoteCount = 1 To ActiveDocument.Endnotes.Count
    Selection.GoTo What:=wdGoToEndnote, Which:=wdGoToAbsolute, _
      Count:=endNoteCount
    curPageNumber = Selection.Information(wdActiveEndPageNumber)
    ActiveDocument.Endnotes(endNoteCount).Range.Select
    ActiveDocument.Application.Selection.Collapse _
      (WdCollapseDirection.wdCollapseStart)
    ActiveDocument.Application.Selection.Paragraphs(1).Range.Characters(3)._
      InsertBefore "Page " & CStr(curPageNumber) & ". "        
  Next
End If    
End Sub

1 个答案:

答案 0 :(得分:0)

CALL