FixMutableDefaultArgumentIssue

Run Settings
LanguagePython
Language Version
Run Command
# Title: "Python None Keyword Usage [Practical Examples]" # URL: https://www.golinuxcloud.com/python-none-examples/ print("Using Python None to fix the mutable default argument issue") # An example of the problem, not the solution # python function def Student(name, details=[]): # appending the value to the list details.append(name) # return the list return details # assigning the name name1 = "Bashir" name2 = "Alam" # calling the function student1 = Student(name1) student2 = Student(name2) # printing print(student1) print(student2) """ The output is as follows: Using Python None to fix the mutable default argument issue ['Bashir', 'Alam'] ['Bashir', 'Alam'] """
Editor Settings
Theme
Key bindings
Full width
Lines