I created a file or module named __init__.py in math folder in VS code to convert the folder into a package

I created a file or module named init.py in the math folder in VS code to convert the folder into a package … but it was not actually reflected… I declared a variable a = 1 in the init.py module when I tried to fetch the package in another module and tried accessing a like this:
import math
print(math.a)
It showed an error it showed that a is not an attribute to the module math… while it didn’t happen the same way in the lecture…can you help???

hey @bihan ,
Actually there is another module in python named math , which while installing any other library might have been installed in yours.
In the video , the mentor used a virtual environment hence he doesn’t have that module and didn’t get any error.
You can try renaming your module.

1 Like

its showing this particular error:- Hello Wolrd!! 13675 Traceback (most recent call last): File “C:\Users\HP\OneDrive\Desktop\coding_blocks_ML_mastercourse\OOPS\modules\math1\simple.py”, line 23, in print(int(sum(24.50, 85.36))) TypeError: ‘float’ object is not iterable

sum function takes a list as input , so provide those 2 float values as a list

1 Like

got it i should try changingthe name of mt function from add to add1 maybe or _add … then it will eork fine…thanx a lot… for helping me out…But One thing why did the same error not happen with Jatin sir when he was teaching?

he might be using a virtual environment or different version of python , where that function is not a default function.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Hey, I am having the same problem. Did changing the math folder into math1 helped?