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

1359 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

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


Write a function that takes a string, and outputs that string formatted in camelcase. (alternating upper and lower case for each character, e.g. cAmElCaSe)


Explain the difference between local and global variables


Define a function that takes in the age of the user and adds it to an output sentence such as "You are ..... old".


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