+ 11
Change variable in first while loop in two while loops, without globals.
a=1 #the variable I want changed while a == 1: b=2 while b == 2: a=3 #this is local, but I want it to affect the a variable on the first line without using global. print(a)
4 Respostas
+ 17
The code above should print 3 for variable a by adding a single line to break nested loop. Am I missing something or is it simply printing the local variable instead?
+ 22
interesting q. bc this variant would work in c#
p.s. I`m not python coder. yet.
+ 15
Glad I helped. c:
+ 11
@Hatsey Rei
nope, I think that's the answer I'm looking for