vendredi 27 août 2021

IndentationError: why "consistent Indentation" throw an IndentationError ? (python) [closed]

block_pick = 1

def update():
    global block_pick

    if held_keys['left mouse'] or held_keys['right mouse']: 
        hand.active()
    else:
        hand.passive()

The code below throw "TabError: inconsistent use of tabs and spaces in indentation"

if held_keys['1']:
    block_pick = 1
if held_keys['2']:
    block_pick = 2
if held_keys['3']:
    block_pick = 3
if held_keys['4']:
    block_pick = 4

But if I indent one more space, it works successfully.

if held_keys['1']:
        block_pick = 1
if held_keys['2']:
        block_pick = 2
if held_keys['3']:
        block_pick = 3
if held_keys['4']:
        block_pick = 4

I can't understand why I have to indent one more space

Aucun commentaire:

Enregistrer un commentaire