Can we pass List as an argument in Python function?

57. Can we pass List as an argument in Python function?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

In a function, we can pass any data type as an argument, such as a string or a number or a list or a dictionary, and it will be treated as if it were of that data type inside the function. The following code exemplifies this –

def St_list(student):
  for x in student:
    print(x)
students = ["Anil", "Rex", "Jerry"]
St_list(students) 

"""
Output:
Anil
Rex
Jerry
"""

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.