#๐Ÿ”’ alot of indent errors :(

20 messages ยท Page 1 of 1 (latest)

inland quail
#
import os
import shutil
from pathlib import Path
FC = {
"Images": [".jpg", ".png", ".gif", ".jpeg", ".bmp", ".tiff", ".raw",".avif"],
"Documents": [".pdf", ".docx", ".txt", ".doc", ".ppt", ".pptx", ".xls", ".xlsx"],
"Videos": [".mp4", ".mpeg", ".mkv", ".srt",".avi"],
"Music": [".mp3", ".wav", ".ogg"],
"Archives": [".zip", ".rar", ".tar.gz"],
"Code": [".py", ".js", ".html", ".css", ".ipynb", ".cpp", ".c"],
"Executables": [".exe", ".msi", ".sh"]
}
SourceFold = Path.home() / "Downloads"
def organize_files(source_path):
 if not source_path.exists():
  print("lol, not found. {source_path}")
  for file in source_path.iterdir():
   if file.is_dir:
    continue

fs = file.suffix.lower()
moved = false
for cat, ext in FC.items():
 if fs in ext:
  dstf = source.path / cat
  dstf.mkdir(exist_ok=true)
  shutil.move(str(file), str(dstf / file.name))
  print(f"Moved {file.name} โ†’ {cat}/")
  moved = True
 break


if not moved:
 others_folder = source_path / "Others"
 others_folder.mkdir(exist_ok=True)
 shutil.move(str(file), str(others_folder / file.name))
 print(f"Moved {file.name} โ†’ Others/")
 print("Your files are moved sir - Construction people in your computer")

if __name__ == "__main__":
 organize_files(sourcefold)```
so, it doesnt seem to get actually working, when i fix an indent: it doesnt output. if i dont, then theres errors.
round emberBOT
#

@inland quail

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

frigid mason
#

!code

round emberBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

frigid mason
inland quail
#

k

frigid mason
frigid mason
# inland quail k

almost, it's better if you also include py just after the three backticks on the opening line, it will color highlight the code

frigid mason
# inland quail k

nice!
now you only need a bit more spaces for each indentation level and your code will be looking much better, and who knows, maybe you'll find the problem with the indentation while increasing the indentation

inland quail
#

okay, brb

#

oh wait it actually works?

#

last time i used the code it had errors

#

yeah i think all i needed to do was the indentation

#

not sure but yeah

frigid mason
#

looks like it should work from a quick look at it, but as i said, it will be easier to find/spot indentation problems if you use more spaces for each indentation level, PEP-8 says 4 spaces for each indentation level is the norm for python

inland quail
#

alr since i solved this ill close the forum

#

!help_forum close

#

!help-forum close

round emberBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.