Ask coding questions

← Back to all posts
I just don't get it
dObbOb11 (1)

I was writing code to handle files and I kept getting an error that didn't make any sense
here is the code (i included it all because I didn't know what caused the error

import os
import shutil
from pathlib import Path

while True:
    command = input("non-public/v1.0.0.1/CLA>")
    if command == "dir.list":
        with os.scandir(input("dir//name>")) as entries:
            for file in entries:
                print(file.name)

    if command == "dir.craft":
         os.mkdir(input("dir//name>"))
         
    if command == "file.delete":
        os.unlink(input("file//path>"))

    if command == "dir.delete":
        os.rmdir(input("dir//path>"))

    if command == "file.copy":
        shutil.copy(input("file//path>"), input("copy//path>"))

    if command == "copy":
        shutil.move(input("path>"), input("copy//path>")
                    
    if command == "file.txt.read":
        with open(input("file.name") as f:
            for line in f:
                print(line)

the error said that the colon was wrong
if command == "file.txt.read":<

Answered by 19ecal (230) [earned 5 cycles]
View Answer
Comments
hotnewtop
19ecal (230)

You're missing a closing bracket at the end of line 25

19ecal (230)

Also one to close the open on line 28