99% of Python coders will get the output of this program wrong!! #pythonsnippets #coding

preview_player
Показать описание
What will be the output of this Python code?
Can you guess?
There is a variable x declared and initialised outside a function and the same variable is assigned a different value inside a function.
The line of code print(x) is just before the second assignment so what will it print?
10 or 20 or will it simply throw an error?

x = 10
def foo():
print(x)
x = 20
foo()

If you already predicted the output before I revealed it in the video then mention it in the comments.

#pythonforbeginners #pythonprojects #python3 #pythontutorial #coding #pythontutorial #programmingtutorial #pythonforeverybody #learnpython #pythonforbeginners
Рекомендации по теме