We have come some way now. And we are going to introduce the important List data type today.
Lists are used in almost every single python script because it is a powerful way to organise and remember information in a program.
I’ll teach you how to create a list, access data in it, find out if information exists in the list or not and ways to add and remove from a list.
This series does not assume you have any prior programming knowledge.
If you are joining us in the middle of this series, the series was designed to be taken step by step. So remember to check out our playlist for the series to find all the videos.
RESOURCES AND LINKS MENTIONED IN THIS VIDEO
00:45 – Introducing Lists
01:41 – Creating Lists
03:21 – Counting Lists
04:02 – Accessing Lists
04:42 – Checking for Membership
05:36 – Slicing Lists
07:27 – Append and Pop
08:40 – Deleting Entries in Lists
09:24 – Introducing the dir() In-built function
10:19 – Debugging a Common List Error
More on Lists:
https://docs.python.org/3/tutorial/datastructures.html
Python for the Anxious Artist Series Playlist: https://www.youtube.com/playlist?list=PLjdX5s0F2DqZYcjKn2QIlNKorQ2E3Lws5
Sign up for my FREE Insider’s Newsletter for More Tips and Insights: https://www.nelsonlim.com/learn/
EXERCISES
# Given a list of houdini scene files,
# can you find and print the latest version?
# *"Extra points" if you can do it without a for loop.
>>> ['fire_v11.hip', 'fire_v01.hip', 'fire_v07.hip', 'fire_v03.hip']
'fire_v11.hip'
# How about printing the earliest version?
>>> ['fire_v11.hip', 'fire_v01.hip', 'fire_v07.hip', 'fire_v03.hip']
'fire_v01.hip'
# I have 2 lists of geometry names.
# Can you combine them into a single list?
>>> ['chair', 'desk', 'lamp']
>>> ['bed', 'rug', 'dresser']
['chair', 'desk', 'lamp', 'bed', 'rug', 'dresser']
# I have a list of geometries containing duplicates.
# Can you print a list without duplicates?
# Extra points if you can do it without a for loop.
>>> ['polySphere1', 'polySphere2', 'polyCube2', 'polySphere2', 'polyCube5',
'polySphere1', 'polySphere8', 'polyCube5']
['polySphere1', 'polySphere2', 'polyCube2', , 'polyCube5', 'polySphere8']
Leave a Reply