I'm using Python in VS code. I am experiencing the error "no module named 'ch6'" when trying to import the functions from one file to another, where the files are located in two different folders.
I have two folders:
- "ch6" – which contain the file "RandomCharacter.py". This file has the functions I want to import.
- "ch7" – which contain the file "CountLettersInList.py" trying to import the functions from "RandomCharacter.py".
If I try to import the functions with the code:
import ch6.RandomCharacter
I get the error: "No module named 'ch6'"
If I use the code:
import RandomCharacter
I get the error: "No module named 'RandomCharacter'"
However, if I copy CountLettersInList.py from folder ch7 to folder ch6, the import works just fine with the code:
import RandomCharacter
So why can't it import the functions successfully when the files are in two different folders?