class Klasa:
def __init__(self,x,y):
self.x = x
self.y = y
def oduzmi(self,x,y):
return x - y
def ispisi(self):
print('rezultat je: ', self.oduzmi(self.x,self.y))
klasa = Klasa(2,3)
klasa.ispisi()
Asked
Active
Viewed 47 times
0
-
1Is that the indentation you are using? It looks like `ispisi` is inside the constructor. – 001 Feb 09 '21 at 18:50
-
It looks like. I moved left( removed indentation), but its giving me the same result. Nothing changes – Miki Feb 09 '21 at 18:58
-
With corrected indentation I get output: https://ideone.com/kSwMwk – 001 Feb 09 '21 at 18:59
-
@JohnnyMopp , you were right it was indentation mistake. Thank you! :) – Miki Feb 09 '21 at 19:05
-
Indentation errors are much easier to spot (and harder to make in the first place) if you consistently use 4 spaces for each level. – chepner Feb 09 '21 at 19:07
-
I am always using tab? Is that ok? – Miki Feb 09 '21 at 19:29
1 Answers
0
Check the indentations please if you are using vscode i suggest you to check Indentation in VS Code
class Klasa:
def __init__(self,x,y):
self.x = x
self.y = y
def oduzmi(self,x,y):
return x - y
def ispisi(self):
print('rezultat je: ', self.oduzmi(self.x,self.y))
klasa = Klasa(2,3)
klasa.ispisi()

mjeday
- 78
- 6