[D]遇到else就出错啊解决方法

[D]遇到else就出错啊......
Python code
{}
>>> a = 1
>>> b = 2
>>> if(a == b)
SyntaxError: invalid syntax
>>> if(a == b):
    print 'true'
    else:
        
SyntaxError: invalid syntax
>>> if(a == b):
    print 'true':
        
SyntaxError: invalid syntax
>>> if(a == b):
    print "true"
    else:
        
SyntaxError: invalid syntax
>>> if(a == b):
    print "true"
    else:
        
  File "<pyshell#30>", line 3
    else:
        ^
IndentationError: unindent does not match any outer indentation level
>>> if(a == b):
    print "true"
     else
     
  File "<pyshell#33>", line 3
    else
       ^
IndentationError: unindent does not match any outer indentation level
>>> for i in[1,2,3,4,5]:
    if i == 6:
        break
    if(i == 2):
        continue
    print i
    else:
        
SyntaxError: invalid syntax

---------------------
Double行动:
原帖分数:40
加分:40

------解决方案--------------------
注意缩进。发代码要把代码放到[code=Python][/code]中,这样行首的空格不会被吃掉。

另外,在python interpreter中输入代码,第二行可是会有‘...’作为提示符,不知为什么你贴的代码里没有。
------解决方案--------------------
缩进不对,python对格式要求非常严格。
------解决方案--------------------
if 和 else 之间的print需要缩进。

>>>if a==b:
... print 'true'
...else:
... print 'false'
------解决方案--------------------
Python code
a = 1
b = 2

if(a == b):
    print 'true'#要缩进
else:
    print 'false'#要和if中的缩进长度一样

------解决方案--------------------
大家基本都说完了,你的问题确实是缩进问题,你把格式好好看下。然后在改一下程序应该就没有问题了。
------解决方案--------------------
难道你的解释器不支持缩进吗?
------解决方案--------------------
if i == 6:
break
if(i == 2):
continue
print i
else:
注意缩进啊,同学
------解决方案--------------------
Python code

if():
   do sth
elif():
   do sth
else:
   do sth