We can pass a list to a function just like other variable.
Passing a
List
We
can pass a list to a function just like other variable. Following example shows
how to pass a list to a function.
def display(numbers):
for n in numbers:
print(n)
my_list = [10,20,30,40,50]
display(my_list)
10
20
30
40
50
Lists
are mutable. That means if we change the list inside a function, then changes
affect the original list.
def fun(numbers):
numbers.append("DDD")
my_list = *"AAA","BBB", "CCC"+
fun(my_list)
print(my_list)
['AAA', 'BBB', 'CCC',
'DDD']

Python for Data Science: Chapter 2: Functions and Files : Tag: Computer Programming, Python, Data Science : - Python: Passing a List in Function
Python for Data Science
AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation
English Essentials II
EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Tamils and Technology தமிழர்களும் தொழில்நுட்பமும்
UC25H02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Linear Algebra
MA25C02 2nd Semester | 2025 Regulation
Applied Physics (CSIE) II
PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Digital Principles and Computer Organization
CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electrical and Electronics Engineering
EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Python for Data Science
AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Re-Engineering for Innovation
ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Python for Data Science - Laboratory
AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation