I know this is a beginner's question. But, I want to know why the list must be declared below the for-loop when passing it as an argument?
def print_list(list):
for i in list:
print(i)
items = ["Bag", "Cellphone", "Laptop"]
print_list(items)
CodePudding user response:
print_list
is a function so you can declare a list below that function or above it doesn't matter. then you pass that list a parameter so it doesn't make sense where the list will be declared below or above the function.
CodePudding user response:
works for me I don't think it matters.