In a Python program, you have a function that sets a greeting message. The function is called 'greet()' and it contains a local variable 'greeting'. Creating another variable with the same name outside this function, you fill it with a different message. After you call the function and print the 'greeting' variable, there are two distinct messages. Understand the behavior of these two variables in different scopes and fill the blanks in the code to output the correct messages.
Global vs local. Scopes
Understanding variable scopes in functions
Report a typo
Fill in the gaps with the relevant elements
greet():
greeting = "Hello, User!"
greeting
greeting = "Hi, User!"
(greet())
print(greeting)Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.