Task 15 - user_guest variable


In task number 15 it asks you to store the returned value into a variable called user_guest.
However didn’t we already do that at task number 5? This feels to me like a duplication of effort, surely the function get_user_guess() already holds the user's guess in the user_guest variable created at task 5.


Hi, @gilla1006 ,

In task 5, you create a local variable named user_guess that is recognized by the Python interpreter only inside the get_user_guess function. The function computes and returns the value of that variable whenever it is called.

In task 15, you call the get_user_guess function and assign the value that it returns to a global variable named user_guess ...

user_guess = get_user_guess()

The fact that the two variables have the same name does not matter; they are different variables.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.