0
How to make a variable which is available in an if statement be available in an else statement in python?
if(1 == 2): ... a = 1 ... b = 1 ... c = a - b ... else: ... print(c + 1) ... #whenever it executes the else statement I get c is not defined
2 Respostas
0
It runs fine when I run it.
0
you have to define c before the if/else statement
c= 0
if ... :
#something with c
else:
# something with c