Problem with code in book

def spam():
eggs = 'spam local'
print (eggs(

def bacon():
eggs = 'bacon local'
print (eggs)
spam()
print (eggs)

eggs = 'global'
bacon()
print (eggs)
1 Like

There’s an error with the closing parenthesis. It should be print(eggs)

Also, Python depends on indentation. The body of a function should be indented by four spaces.

Here’s a working version:

def spam():
    eggs = 'spam local'
    print(eggs)

def bacon():
    eggs = 'bacon local'
    print(eggs)
    spam()
    print(eggs)

eggs = 'global'
bacon()
print(eggs)

Let us know if you have more questions.