+ 2
What is a method and when use a method
5 Antworten
+ 2
A method is a function that belongs to an object. Use it when you want to do something with the object.
+ 2
Oh found one "In Python, a method is a function that is available for a given object because of the object's type. For example, if you create my_list = [1, 2, 3] , the append method can be applied to my_list because it's a Python list: my_list.append(4) . All lists have an append method simply because they are lists"
+ 1
Methods are useful becaude they:
~make code more readable
~prevent name conflicts
~help separating different tasks for different objects
0
Examples pls
0
Timour Zinaliyev Yes, and if there was another datatype, such as set, that also would have had an append method, no name conflicts would happen due that.