NumberGuess game bug with indentation?


Hi everyone, this is my first post in this forum :slight_smile:

The thing is… i have a problem with the NumberGuess game in Function Level of Learn python course.
This is my code, and i thing is right. Please check below:

"""Este programa fará as seguintes ações:
Rolar os dados; Adicionar o valor o resultado obtido da jogada; Pedir ao jogador para adivinhar e inserir um valor; Comparar os valores inseridos pelo utilizador, com os obtidos na jogada; Determinar o vencedor (Utilizador ou computador)"""

from random import randint
from time import sleep
def get_user_guess():
  guess = int(raw_input("Insira a sua aposta de resultado para a jogada dos dados: "))
  return guess

def roll_dice(number_of_sides): 
  first_roll = randint(1, 6) 
  second_roll = randint(1,6) 
  max_val = 6 * 2
  print "O valor máximo possivel é %d" % max_val
  guess = get_user_guess()
  if guess > max_val:
		print "O resultado apostado é demasiado elevado"
    print "Rolling..."
  	print 'Resultado da primeira rodada: %d ' % first_roll
    print 'Resultado da segunda rodada: %d ' % second_roll
    total_roll = first_roll + second_roll
    print 'O resultado total é: %d' % total_roll
    print "Result..." 
    if guess == total_roll:
      print "Ganhou!"
    else guess != total_roll:
      print "Perdeu!"

-------------------------------------------------- code above------

When i put python + enter in console, it alert this:

$ python
File “”, line 21
print 'Resultado da primeira rodada: %d ’ % first_roll
IndentationError: unexpected indent

I don´t see any indentation problem with line 21 or in any other line in this code.

I can´t put corret indentation in this post, so i put this print of code:

I appreciate any help.

Anyone can help me? :roll_eyes:


this is a screenshot of your code:


you can see the indent problem? This is not your fault, the editor uses hard-tabs, and this sometimes messes stuff up. Re-indenting around line 21 should fix it.


Tks, I am doing my first´s stapes in programming and i appreciate the clarification :+1:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.