Ask coding questions

← Back to all posts
Indentation error

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

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.


@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'


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


@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).