What is the difference between a list and an array?

Lists are part of Python's syntax and hence do not need to be declared. However, performing functions such as dividing every entry in the collection by an integer by simply writing xs/2 is not possible with lists, only arrays. In Python, both lists and arrays can both be iterated over and indexed into, and can store any data type. Arrays are more compact and efficient and can perform more arithmetic functions.

LW

Related Python Mentoring answers

All answers ▸

How would you get a piece of code to print the numbers 1 to 10


Which function is ran when an object is instantiated?


How could I write a program to convert Km/h to m/s in python


What is the difference between using range() and a list of values?