Unpacking Lists Workout
- 01:24
Practice unpacking lists in Python.
Downloads
No associated resources to download.
Glossary
lists Machine Learning PythonTranscript
In your Jupyter Notebook, unpack results into the new variables, input train, then input, test, target, train, and finally, target test. Then display the dimensions of each new object to verify that they were defined and unpacked correctly.
During the lesson, you should have already written the code that you see here, importing the train test split function, and then executing the train test split function to create this results variable. You also should have completed the code that you see here to make sure that all of that was executed correctly.
We're unpacking that results variable, which is a list into these four new variables. Input train, input test, target train, and target test. Since results is a list containing four objects by creating four new variables, it's going to unpack that list where each of the objects is going to go into each of these variables in order to make sure that it's done correctly, we're printing the shape of each of these new objects, and when you execute that cell, you should see the results right here. To further verify that all of that was done correctly, you can display the first row of each of these objects and they should match what you see here.