Download presentation
Presentation is loading. Please wait.
1
Lists in Python Parallel lists
2
Parallel lists This is a technique for using lists which goes back to the early days of programming It’s not new syntax, just a slightly different way to look at arrays Many languages have a restriction that an array can be only one type, an integer array, a string array, etc.
3
Sometimes the situation required storing both floats and strings, for example (GPAs and names).
One piece of data, a GPA, belongs with another piece of data, a name. Since they could not be put in the same array, they were put in separate arrays, but in the same position.
4
Parallel arrays By using the same subscript for both arrays, you are referring to related data. The main thing to remember is if you move data around in one of the arrays, you must make the same moves in the other array Nothing in the language enforces this relationship, it’s up to your programming
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.