python - IDLE idents are 8 spaces instead of 4 - is it a syntax error? -
i new python , have come across weird issue code. know question has been asked before cannot seem find errors in code related other posts.
whenever press [tab], there 8 space indent pose 4 space indent other documents have specified in options. havn't commented code because think problem me having bracket or similar knowing code meant wouldn't make difference. here code:
import os.path import time def writeline(localfile,lines,currentline): if lines==(currentline-1): print("writing document.") print("the document has been written to.") else: writecontent = input("what write line " + str(currentline) + "?\n") currentline = currentline + 1 write_doc = open(localfile, "a") if lines==(currentline-1): write_doc.write(writecontent) else: write_doc.write(writecontent + "\n") write_doc.close() writeline(localfile,lines,currentline) def writedoc(localfile): lines = int(input("how many lines document have?\n")) currentline = 1 time.sleep(0.5) writeline(localfile,lines,currentline) def checkdoc(localfile,localmode): print("verifing file") time.sleep(0.5) if localmode!="w": if os.path.isfile(localfile): print("the file exists. proceeding.") time.sleep(0.5) writedoc(localfile) else: print("the file not exist. please either create file or use write function create it.") time.sleep(0.5) start() else: if os.path.isfile(localfile): print("the file exists. modify file, please use amend function.") print("the file not exist. creating file.") time.sleep(1) create_doc = open(localfile, "w") create_doc.write("") create_doc.close() if os.path.isfile(localfile): print("file created successfully.") writedoc(localfile) else: print("the file couldn't created. please ensure that...\n a) have full admin privileges\n b) file path correct\n c) if else fails, try running in elevated session.") def start(): file = input("please enter full file path of file wish use\n") time.sleep(0.5) mode = input("what file, read, write, append or read/write ('r', 'w', 'a' or 'r+')\n") time.sleep(0.5) checkdoc(file,mode) start()
sorry posting whole thing, have no idea error occuring. i'm sure it's simple typo no matter how look, cannot find it. if let me know have gone wrong, great!
i managed find fix, copperfield. went through of code , removed of weird indents , set normal. problem started me accidently pressing [tab] twice! oops!
thanks help! reece coombes
Comments
Post a Comment