How do you fix unindent indentation error

how do you fix this error:

Repl link:

	while not(len(word) == 5):
		write = open("words.txt", "w").write("brake\nbreak\napple\ngrape\nchair\ngrain\nhorse\nshark\ntrain\ntrail\ncrown\nqueen\nsouth\nnorth\nocean\nprint\nsword\ntable\nalien\njesus\ncouch\nbrand\nstore\ngreat\nsuper\nframe\nimage\nseven\nboard\nstink\nenter\nlevel\nshell\nspoon\nforks\npaper\nknife\nmouse\nriver\nhouse\nstart\npixel\nforce\nwatch\nlater")
    lines = len(open("words.txt").readlines())
    line = random.randint(0,lines) 
    mincol = line * 6
    maxcol = mincol + 5
    read = open("words.txt").read()
    word = open("words.txt").read()[mincol:maxcol]
    file = open("words.txt").close()
code snippet

This is a problem when you are using tabs and also spaces. You have to use one or the other. Your first two lines are using tabs, whereas the rest are using 4 spaces.

edit: looking at the full code, it looks like the whole program is using tabs, but the section from lines 56-62 are using 4 spaces. So maybe the person who first did the code was using tabs, but then another person added to it and used spaces. It is one reason I make all my students set up their settings to use spaces and 4 spaces per indent, so we’re all on the same page for indents.


yeah yesterday in setting i change my indent type from tabs to spaces

If you find some answer did solve your question you can click the little tick next to the comment so that people won’t come in and check the question that is already solved

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.