0
Difference between methods and functions?
I thought I understood but clearly not. What is the difference? My understanding was that a method actually changed the object it was acting on and a fun toon just returned something. I.e. . append () actually changes something where is Len() doesn't. But then I came across the method .count(). Why is this a method? It's not changing anything, just counting the instances of a given something. Probably haven't explained that very well...
6 Respuestas
+ 3
I explain it simply : a method is a function that belongs to an object. Learn OOP to understand the difference better.
+ 2
we have a bit similar discussion here, maybe you can join
https://www.sololearn.com/discuss/2184025/?ref=app
+ 1
Here, count belongs to an object of type 'list'.
+ 1
Penny's dropped. Thanks a lot!
0
So I've just done a module on OOP. I get what a class is and an object. So in that example, what is the object count belongs to?
0
a method