Lists


#Lists

listOfLights = ["keyLight", "sideLight", "backLight", "fillLight"]

print(listOfLights[0])

print(listOfLights[2])

print(listOfLights[3])

print(listOfLights[-1])

print(listOfLights[0:2])

#subsets of lists with slicing

print(len(listOfLights))

#when index is negative count from end of list backwards

listOfLights = ["keyLight", "sideLight", "backLight", "fillLight"]

listOfLights.sort()

print(listOfLights)

listOfLights.reverse()

print(listOfLights)

listOfLights.append("newLight")

print(listOfLights)

#The sort() method sorts the list ascending by default.

#The reverse() method reverses the sorting order of the elements.

#The append() method appends an element to the end of the list.

keyLight

backLight

fillLight

fillLight

['keyLight', 'sideLight']

4

['backLight', 'fillLight', 'keyLight', 'sideLight']

['sideLight', 'keyLight', 'fillLight', 'backLight']

['sideLight', 'keyLight', 'fillLight', 'backLight', 'newLight']

Leave a comment

Log in with itch.io to leave a comment.