can't call the class outside of it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

can't call the class outside of it

I have written this code and I can use it only when I call it inside it like this: class Taraz: def __init__(self, filepath): scores = pd.read_excel(filepath)['point'] self.mean = scores.mean() self.var = scores.var() def score(self, score): return (score - self.mean) / self.var if __name__ == '__main__': taraz = Taraz(path.join(r'C:\Users\dell\Desktop\book1.xlsx')) print(taraz.score(16)) in this form it works properly but when I use print func outside the class it gives an error.I want to know why is that and how can I solve this problem?

4th Oct 2020, 8:21 AM
Inifnite Science
Inifnite Science - avatar
3 Answers
0
Could you put the code in the playgound and link it here? From here it looks like an indentation issue, but you never know.
4th Oct 2020, 8:29 AM
Slick
Slick - avatar
0
well I'm sure it is not indentation problem.I couldnt enter my code in the play ground. sorry
4th Oct 2020, 8:38 AM
Inifnite Science
Inifnite Science - avatar
- 1
Ahh too bad
4th Oct 2020, 8:40 AM
Slick
Slick - avatar