python - why am i getting “inconsistent use of tabs and spaces in indentation”? -
this code:
x = []; y = []; xx = [] xy = [] # variable show if file openening worked opened = 0; # try open file try: readfile = open('xydata.txt', 'r'); # if open file worked opened = 1; except: # if opening file went wrong print('some error occured!'); #next line same if opened == 1 if opened: # read in data file line line line in readfile: # variable line holds 1 of lines # in data file # split in string 'line' based on whitespace splitup = line.split(); # x = splitup[0], y = splitup[1] # append arrays x , y x.append(splitup[0]); y.append(splitup[1]); xx.append(splitup[0]*splitup[0]); xy.append(splitup[0]*splitup[1]); # close file readfile.close(); print('done')
there more @ point get:
run lobf.py file "/users/paulbebb/desktop/pyscripts/lobf.py", line 56 x.append(splitup[0]); ^ taberror: inconsistent use of tabs , spaces in indentation
and cannot seem work out problem. in advance.
it looks have weird mix of tabs , spaces. stick using tabs or spaces. code below uses spaces. try copy pasting code below editor.
x = [] y = [] xx = [] xy = [] # variable show if file openening worked opened = 0 # try open file try: readfile = open('xydata.txt', 'r') # if open file worked opened = 1 except: # if opening file went wrong print('some error occured!') #next line same if opened == 1 if opened: # read in data file line line line in readfile: # variable line holds 1 of lines # in data file # split in string 'line' based on whitespace splitup = line.split() # x = splitup[0], y = splitup[1] # append arrays x , y x.append(splitup[0]) y.append(splitup[1]) xx.append(splitup[0]*splitup[0]) xy.append(splitup[0]*splitup[1]) # close file readfile.close() print('done')
Comments
Post a Comment