0
I already the pass the 3 arguments but show there are 2 arguments are missing
class stu: def __init__(s,name,city): s.name = name s.city = city def show(s,name,city): print("1",s.name) print("2",s.city) p = stu("yakin","newyork") p.show()
5 Réponses
+ 1
def show( s ):
You don't need <name> or <city>, you will get those values from properties of object <s>
+ 1
You don't need to pass them when you want to display them. See the object <s> refers to a `stu` instance, and it is expected to have properties named <name> and <city>.
Which part is confusing you BTW?
+ 1
s already got name and city as properties because of what you declared in __init__. Just pass s as an argument for show() and use s.name and s.city in your print() function.
https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_classes.asp
0
Then how pass your value to given method