I'm doing a udemy programming course and as part of that they had me write this code:
import os
listing = os.walk('.')
for root, directories, files in listing:
print(root)
for d in directories:
print(d)
for file in files:
print(file)
since then, whenever I run any python program, even if it is this:
statement_1 = False
statement_2 = True
if statement_1 == True:
print("Statement 1 is true")
elif statement_2 == True:
print("Statement 2 is true")
else:
print("both statements are false")
I get this error: C:\Users\Reinout\AppData\Local\Programs\Python\Python37-32\python.exe "C:/Users/Reinout/IdeaProjects/Learning projects/test.py" Fatal Python error: initsite: Failed to import the site module Traceback (most recent call last): File "C:\Users\Reinout\AppData\Local\Programs\Python\Python37-32\lib\site.py", line 73, in import os File "C:\Users\Reinout\IdeaProjects\Learning projects\functions**os**.py", line 3, in listing = os.walk('.') AttributeError: module 'os' has no attribute 'walk'
So the question is: why do i get errors for a different program when it doesn't even have anything to do with the program I'm running? I'm not trying to import the os module right now. and even if I was, it definitely does have the attribute 'walk'. I can click on it to see the documentation.