Middle slice : Slice : List PYTHON TUTORIALS


PYTHON TUTORIALS » List » Slice »

 

Middle slice


monthList = ["January""February""March",
             "April""May""June""July"
             "August""September","October",
             "November""December"]

wordCount = len(monthList)
halfCount = wordCount/2

firstHalf = monthList: halfCount]

wordCount = len(firstHalf)
middleStart = wordCount/2
middleHalf = monthList[middleStart : middleStart+halfCount]
print middleHalf



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo List
» Slice