我一直在尝试运行这些代码块,但它一直没有给出语法错误
var1 = 100
if var1: print "1 - Got a true expression value"
print var1
else:
print "1 - Got a false expression value"
print var1
var2 = 0
if var2: print "2 - Got a true expression value"
print var2
else:
print "2 - Got a false expression value"
print var2
print "Good bye!"
答案 0 :(得分:0)
问题在于你的缩进可能。 这是缩进代码 -
var1 = 100
if var1:
print "1 - Got a true expression value"
print var1
else:
print "1 - Got a false expression value"
print var1
var2 = 0
if var2:
print "2 - Got a true expression value"
print var2
else:
print "2 - Got a false expression value"
print var2
print "Good bye!"
1 - Got a true expression value
100
2 - Got a false expression value
0
Good bye!