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 do For Loops work?


Write a function that checks whether a number is prime or not.


Implement a rocket launch countdown.


Make a program that asks the user for a series of numbers until they either want to output the average or quit the program.