Quiz Question 1 of 5
Consider the following code. Which statement about the data
variable is true?
def modify_data():
data.append(4)
print("Inside function:", data)
data = [1, 2, 3]
modify_data()
print("Outside function:", data)
Choose the correct answer below:
-
A
data
is a global variable, and changes made insidemodify_data()
are reflected outside the function. -
B
data
is undefined outsidemodify_data()
. -
C
data
is a local variable insidemodify_data()
, so changes are not reflected outside. -
D
data
is a global variable, butmodify_data()
creates a new local variable with the same name.