Ask coding questions

← Back to all posts
Indentation error
y33t3rs0n

I'm adding to a python tutorials project and I have an indentation error which I've tried fixing many times but failed could someone help?

Answered by Wumi4 [earned 5 cycles]
View Answer
Voters
y33t3rs0n
Comments
hotnewtop
Wumi4

It looks like on line 47 to line 56, in the if, elif and else blocks, you use a space for indentation instead of tabs like the rest of the code. Fix that by remove the indentation space and replace it with tabs.

y33t3rs0n

@Wumi4 Thanks but now I have type errors kekw: TypeError: attack() missing 9 required positional arguments: 'lives', 'weapon_damage', 'coins', 'monsters_killed', 'bright_yellow', 'bright_blue', 'green', 'bright_red', and 'bright_cyan'

and:

Traceback (most recent call last):
File "main.py", line 54, in <module>
print(bright_yellow + "\nYou have" + coins + "coins!!")
TypeError: can only concatenate str (not "int") to str

Wumi4

@y33t3rs0n The first error is because when you called the function attack, you forgot to give it enough arguments. The function requires 9 arguments, while you give it 0 arguments.

The second error is because the coins seems to be an int, not str, you can convert it to str by using the str() function, like str(coins).