Search code examples
pythonwhile-loopindentationraw-input

unexpected indent raw_input on while


def teste():
  resp=raw_input("Quer fazer o teste: ")
  while resp=='s':
    dim=input("Qual o tamanho do tabuleiro: ")
    x=input("Qual a posicao x da peca: ")
    y=input("Qual a posicao y da peca: ")
    mov_sem_obst(x, y,dim)
    raw_input("Quer continuar? ")

teste()

This code should run the function mov_sem_obs every time when I answer s on resp but when I compile I have a problem with the identation of raw_input on the while.


Solution

  • First you need to assign resp to your raw_input. So resp=raw_input("Quer continuar? "). Also, if you're having problems with indentation of that line, you need to check if you're using tabs or spaces and properly move that line into place