一旦列表仅剩两个元素,则需要删除每三个元素并返回它

时间:2018-11-05 04:12:49

标签: python-3.x

需要删除每个第三个元素,并在列表中仅剩两个元素时将其返回

npm uninstall -g sass

1 个答案:

答案 0 :(得分:0)

以下是您的操作方法的简短摘录,

        Do While wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column) <> ""

        currCell = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column)           
        currDlUarfcn = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column + 3)
        currPsc = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column + 4)
        currRootSeqIdx = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column + 5)
        currZone = wkbSource.Sheets("WorkingSheet").Cells(lin1, rng.Column + 6)
        currCellId = Right(currCell, 1)

        'Enter data in first Page
        Site.txtLteCellName = currCell
        Site.txtLteCellId = txtLteBtsId
        Site.txtLteUarfcnDl = currDlUarfcn
        Site.txtLteAzimuth = currAzimuth
        Site.txtLtePsc = currPsc
        Site.txtLteTac = currTac
        Site.txtLteRsi = currRootSeqIdx
        Site.txtLteLoCellId = currLoCellId
        Site.txtLteSector = currSector
        Site.txtLteSectorEq = currEquipmentId
        Site.txtLtePower = "40W"
        Site.txtLteCabinet = currCabinet
        Site.txtLteSubrack = currSubrack
        Site.txtLteSlot = currSlot

        'Create new page, copy and paste textBoxes
        Dim l As Double, r As Double
        Dim ctl As Control

        MultiPage4.Pages.Add

        MultiPage4.Pages(0).Controls.Copy
        MultiPage4.Pages(1).Paste

         For Each ctl In MultiPage4.Pages(0).Controls
            If TypeOf ctl Is MSForms.Frame Then
                l = ctl.Left
                r = ctl.Top
                Exit For
            End If
        Next

        For Each ctl In MultiPage4.Pages(1).Controls
            If TypeOf ctl Is MSForms.Frame Then
                ctl.Left = l
                ctl.Top = r
                Exit For
            End If
        Next

        lin1 = lin1 + 1

    Loop

输出:

names = ["sasha", "nathan", "jennie", "shane", "will", "sara"]

def removeThirdName(names): 

    pos = 3 - 1
    index = 0
    len_list = (len(names)) 

    while len_list > 2:  

        index = (pos + index) % len_list 

        print(names.pop(index))
        len_list -= 1

removeThirdName(names)
print(names)