Question: The variable color is a local variable - it is unique only to the green function. If we attempt to run this code, it will

The variable color is a local variable - it is unique only to the green function. If we attempt to run this code, it will fail because color does not exist within the scope of the fav_color function.
Re-write the code so the variable color, is passed as an argument from green to fav_color.
When you are finished, the output should match that under Desired Output# Define the green function
def green():
color = "green"
fav_color()
# Define the color function
def fav_color():
print("My favorite color is",color)
# Call the green function
green()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!