Comprender el alcance
¿Qué cuatro valores imprime este script?
x = 50
def one():
x = 10
def two():
global x
x = 30
def three():
x = 100
print(x)
for func in [one, two, three]:
func()
print(x)
Este ejercicio forma parte del curso
Escribir funciones en Python
Ejercicio interactivo práctico
Pon en práctica la teoría con uno de nuestros ejercicios interactivos
