-3

I did write this code in pygame if that has something to do with it.

if x<=-50: # This is line 91 in a while loop no other indents needed
    x=-50

elif x>=1200:
    x=1200

Here's the error I got:

    Traceback (most recent call last):
  File "C:\Users\Dell\Desktop\Zombie survival\Gun_Boi_and_Zombie_Boi.py", line 3, in <module>
    from Main_Menu_Gun_Boi import mainmenu
  File "C:\Users\Dell\Desktop\Zombie survival\Main_Menu_Gun_Boi.py", line 91
    
    ^
IndentationError: expected an indented block

I haven't touched this piece of code in a while, and this just happened out of the blue. And the pointer doesn't help at all.

  • 1
    Where is this code fragment. Python is complaining about Main_Menu_Gun_Boi.py line 91. Is this that file? What line numbers? – tdelaney Nov 23 '21 at 02:43
  • 1
    So far, you've given us 5 lines of code, no hint where in this file. Suppose that line 90 was a dangling `if whatever:` and line 91 was 4 spaces, but nothing else. And then end of file. This is the error you would get. So, look at that file, look at line 91 and look at what is directly above it. – tdelaney Nov 23 '21 at 02:59
  • Voting to reopen. The exception is unambiguously clear as to what the problem is, as reflected in the answers that have already been provided. – joanis Nov 23 '21 at 16:12
  • Although it's a duplicate - see https://stackoverflow.com/q/4446366/3216427 and https://stackoverflow.com/q/492387/3216427. This question would be better closed as duplicate than as lacking details or clarity. – joanis Nov 23 '21 at 16:14
  • Okay, I figured it out. It was talking about the other file I was using, Main_Menu_Gun_Boi. Not the one I showed. :| – Turboluck102 Nov 24 '21 at 00:41

3 Answers3

1

Switch your IDE to use spaces instead of tabs. In VSCode's case go to the button that says Tabs: 4, click on it and select Spaces then select 4. This should fix your problem for the individual file but to permanently switch it to spaces: Open setting.json using command pallette --> add editor.insertSpaces: true.

ani
  • 190
  • 2
  • 12
1

Double check that you consistently use either spaces or tabs. Mixing them will cause all kinds of trouble. You can enable your editor's option to show you whitespace caracters to help with keeping this consistency.

Code-Apprentice
  • 76,639
  • 19
  • 130
  • 241
-3

Look at the top lines of your code at the import... No spaces should be in front of the word "from"

In the following line (the error code claims it is there even though you didn't post it...

Look to line 91 in method file... survival\Main_Menu_Gun_Boi.py

GT Electronics
  • 130
  • 1
  • 8