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
Answered by Liora W. Python tutor

1364 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

how to compute the factorial of a number.


Write a function that takes a list of numbers as input, and outputs the average of the numbers. The function should catch any errors.


How can you take a list of numbers and add 3 to every number in the list using only one line of code?


How does a for loop work in Python?


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences