python referenced before assignment in function 1

python referenced before assignment in function

# When Python parses the body of a function definition and encounters an assignment such as

 feed = 5 
#Python interprets feed as a local variable by default. If you do not wish for it to be a local variable, you must put

global feed
feed = 5

Here is what the above code is Doing:
1. The function is called with a single argument, the number of seconds to sleep.
2. The function sleeps for that amount of time.
3. The function returns the string ‘Wake up!’

Similar Posts