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']
Programming Progress Log
More posts
- List FunctionsNov 14, 2022
- Python Classes/ObjectsOct 24, 2022
- While LoopsOct 24, 2022
- LoopsOct 16, 2022
- Short Circuit PracticeOct 16, 2022
- Using VariablesOct 15, 2022
- Converting degrees to farenheitOct 15, 2022
- First CodeOct 15, 2022
Leave a comment
Log in with itch.io to leave a comment.