Python-Questions: Count Prime Numbers upto the given input number

Python Question – 3

Count Prime Numbers up to the given input number

I think this is the error I get:
Traceback (most recent call last):
File “./”, line 29, in
if not os.path.exists(path):
TypeError: ‘NoneType’ object is not subscriptable



You have to use os.stat() to check if the path exists.
import os
path = 'C:/Users/my_user/Desktop/myfile.txt'
if not os._stat(path, os.S_ISDIR):
Edit: This is because you are using Python 3.x.
You can use os._path.join to join the path with the current working directory.
If you want to avoid the use of os.chdir, you can use the os.makedirs() function.

Leave a Reply

Your email address will not be published. Required fields are marked *