Python taberror选项卡和空格的使用不一致

Python taberror选项卡和空格的使用不一致,python,python-3.x,Python,Python 3.x,我在(返回不是交替)时遇到问题。错误是“空格使用不一致”。有人能帮我吗。 我尝试使用适当数量的制表符和空格,但问题仍然存在 def alternating(list): listDifference = [] if list == []: return True alternating = True lPos = 0 rPos = 1 #appends the difference between values to a new lis while (lPos

我在(返回不是交替)时遇到问题。错误是“空格使用不一致”。有人能帮我吗。 我尝试使用适当数量的制表符和空格,但问题仍然存在

def alternating(list):
  listDifference = []
  if list == []:
    return True
  alternating = True
  lPos = 0
  rPos = 1
  #appends the difference between values to a new lis
  while (lPos < len(list)-1) and (rPos < len(list)):
    listDifference.append(list[lPos] - list[rPos])
    lPos += 1
    rPos += 1
  #resets the position
  lPos,rPos = 0,1
  #checks whether values are alternating or not
  while (lPos < len(listDifference)-1) and (rPos < len(listDifference)):
    if listDifference[lPos] < 0:
      if listDifference[rPos] > 0:
        lPos += 1
        rPos += 1
      else:
        return not alternating
    elif listDifference[lPos] > 0:
      if listDifference[rPos] < 0:
        lPos += 1
        rPos += 1
      else:
        return not alternating
  return alternating
def交替(列表):
listDifference=[]
如果列表=[]:
返回真值
交替=真
lPos=0
RPO=1
#将值之间的差异追加到新lis
而(LPO0:
lPos+=1
RPO+=1
其他:
不交替返回
elif listDifference[lPos]>0:
如果listDifference[RPO]<0:
lPos+=1
RPO+=1
其他:
不交替返回
回程交替

您的问题是,您同时使用制表符和空格,这会产生错误,因此您只需要使用制表符或空格

您需要使用制表符或空格。在Python3中,不能同时使用这两种语言。