-3

I am a beginner and need help with a bit of code:

    print('welcome to multiply land, where you must earn respect by getting questions correct')
want_to_play = input('want to play. y/n    ')


    
if want_to_play == 'y':
    high = int(input('what is the highest times table you want?'))
    low = int(input('what is the lowest times table you want?'))
    os.system('cls' if os.name=='nt' else 'clear')
    print('ready')
    time.sleep (1)
    os.system('cls' if os.name=='nt' else 'clear')
    print('steady')
    time.sleep (1)
    os.system('cls' if os.name=='nt' else 'clear')
    print ('go')
    time.sleep (1)
    os.system('cls' if os.name=='nt' else 'clear')

    while lives > 0:
     os.system('cls' if os.name=='nt' else 'clear')
     digit1 = random.randint(low, high)
     digit2 = random.randint(low, high)
     print('♡ = {lives}'.format(lives=lives))
     print('respect = {respect}'.format(respect=respect))
     anser = int(input('{digit1} X {digit2}    '.format(digit1=digit1, digit2=digit2)))
     if anser == digit1 * digit2:
      os.system('cls' if os.name=='nt' else 'clear')
      respect += random.randint(1, 5)
      print('well done')
  
  else:
   life -= 1 
else:
 print('bye')

but more specifically:

print('respect = {respect}'.format(respect=respect))
anser = int(input('{digit1} X {digit2}    '.format(digit1=digit1, digit2=digit2)))
if anser == digit1 * digit2:
  os.system('cls' if os.name=='nt' else 'clear')
  respect += random.randint(1, 5)
  print('well done')

this ( os.system('cls' if os.name=='nt' else 'clear')) is where the error occurs, any help is exepted.

I have tried replacing tabs with spaces and spaces with tabs and please comment if you need more information.

thanks

PS. this is all of the code but is it not complete

Aidan
  • 42
  • 6
  • 1
    It is recommended to use 4-space indentation. It looks pleasing to eyes and easier to detect any indentation error –  Jul 04 '21 at 16:39
  • 1
    The error message means exactly what it says. Make _all_ your whitespace consistent -- the spacing for the line doing the dedent needs to be completely, 100% identical to the last code at that indentation level. Normalizing on using only 4 spaces is, as suggested by Sujay, the common best-practice approach. – Charles Duffy Jul 04 '21 at 16:40
  • Everything below the ```print``` statement is indented to the right by one-space. –  Jul 04 '21 at 16:41
  • BTW, welcome to Stack Overflow! Please take the [tour] and read [ask]. – wjandrea Jul 04 '21 at 16:49

1 Answers1

1

I believe that you have indented your code incorrectly

print('respect = {respect}'.format(respect=respect))
anser = int(input('{digit1} X {digit2}    '.format(digit1=digit1, digit2=digit2)))
if anser == digit1 * digit2:
  os.system('cls' if os.name=='nt' else 'clear')
  respect += random.randint(1, 5)
  print('well done')

I would also recommend that you look at the pep8 guidelines

Ali Awan
  • 180
  • 10