This forum is now read-only. Please use our new forums! Go to forums
Possible issue (and solution) to many of the errors
I had error messages from the code I entered even though I could not find any problems either, as many of you have posted. I even ran it through the python interpreter and that worked fine, so I presumed it was this website. I was playing with indenting (because as well all know, whitespace is important! :) ) when I came upon the solution purely by accident… The answer? Spaces vs. Tabs!
If you are getting the error and you’re sure your code is good, try this (at least it worked for me):
- put your cursor at the beginning of a line that starts ‘elif’ or ‘else’ (it should be indented).
- hit the <backspace> key.
- if the cursor goes all the way to the beginning of the line, it was a <tab> character. replace it with 4 (four) spaces (i.e., hit <space bar> 4 times).
That should do it! Repeat for any ‘elif’ or ‘else’ lines you might have.
The caveat is, when you hit <backspace> in step 2, it only goes back one space instead of to the beginning of the line, there is another error and this solution won’t help you.
Hope this helps!
Answer 5100c851b58f038cb9001545
thank you so much!! I was working on this for a week trying to figure out what the hell was going on. I added spaces instead of using tab and it worked
Answer 510f42edf2d6782f5d0033bb
Thanks Dan. Yet I tried this and it’s still sending me error messages. : (
Answer 53f029ce52f86318f3000773
Thanks a lot! replacing the “tab” with 4 spaces worked for me
Answer 5463abca52f863fa060007ed
I’ve tried using both tab and for space and neither work. I’m still being told there is an indentation error.
1 comments
It eventually worked AFTER I erased the pre-written code and wrote it over again.
Answer 512c16fcfb0e1af186000029
Answer 52504c02548c358125009569
In addition to checking the spacing for me I had to make the last “return” line not indented/spaced at all. Also it requires that the colon be dropped (lol) at the end of the “else” line and added just after the “else:”
else: 1 == 1 and 2 == 2
return True
#obviously your other code would be above these lines
Answer 5388077b9c4e9d5c1e001ecd
File “python”, line 6 elif 70 - 4 == 3 : ^ SyntaxError: invalid syntax huh?
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
2 comments
language?
If I may Mr. Miguelgorry, I am very thankful as well. I am grateful for this gentleman’s aid.