Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Can anyone please help me? I can't understand why my code is being rejected.

+5 votes
asked Oct 1 by Yoong Tsun Chuen (550 points)

1 Answer

0 votes
answered Oct 1 by Peter Minarik (63,140 points)
selected Oct 1 by Yoong Tsun Chuen
Best answer

If you read the error message, you'd see immediately what the problem is:

  File "main.py", line 43
TabError: inconsistent use of tabs and spaces in indentation

You're only allowed to use either spaces or tabs for indentation. And that's an exclusive or. If you use tabs, you cannot use spaces. Stick with one, do not switch around.

Starting from line 20 you've got mixed tabs and spaces indentation. I suggest copying all your code into a text editor where you can display white space characters and make sure you use all tabs or all spaces, not mixed up.

Also, you should call your battlecode_() function to make anything happen. E.g. do it at the last line (without any indentation)

Your while loop seems to have the wrong logic too. I think this would be the right logic:

while mercy == 0 and hp > 0 and crabhp > 0:

I see your code is ufinished. Keep working, reading the error messages and fixing things accordingly.

commented Oct 1 by Yoong Tsun Chuen (550 points)
Thank you.

I just did not understand the error message so thank you for clearing it up.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.