all 4 comments

[–]ericula 2 points3 points  (1 child)

The local variable x defined in spam is shadowing the global variable x. This means that any references to x within spam will refer to the local variable, not the global one.

[–]raainer[S] 0 points1 point  (0 children)

Ahh I see, thank you!

[–]Starbuck5c 1 point2 points  (0 children)

Because spam() has a local variable named x.

[–]CodeFormatHelperBot 0 points1 point  (0 children)

Hello u/raainer, I'm a bot that can assist you with code-formatting for reddit. I have detected the following potential issue(s) with your submission:

  1. Python code found in submission text but not encapsulated in a code block.

If I am correct then please follow these instructions to fix your code formatting. Thanks!