Python List object attribute 'append' is read-only

后端 未结 2 1309
生来不讨喜
生来不讨喜 2021-02-19 09:01

as the title says, in python, I\'m trying to make it so when someone types in a choice (in this case Choice13) then it deletes the old password from the list passwords and adds

2条回答
  •  别跟我提以往
    2021-02-19 09:13

    To append something to a list, you need to call the append method:

    passwords.append(Choice13)
    

    As you've seen, assigning to the append method results in an exception as you shouldn't be replacing methods on builtin objects -- (If you want to modify a builtin type, the supported way to do that is via subclassing).

提交回复
热议问题