Reputation: 174
I have this code.
START_STAT =(
[ 4, 3, 6, 3, ],
[ 3, 3, 4, 6, ],
[ 3, 5, 5, 3, ],
[ 4, 6, 3, 3, ],
[ 4, 3, 6, 3, ],
[ 3, 3, 4, 6, ],
[ 3, 5, 5, 3, ],
[ 4, 6, 3, 3, ],
)
And i want to update one with one more line
START_STAT.update{[ 6, 2, 2, 6, ]}
What is wrong there ? I tried also with + but same , error.
START_STAT +={[ 6, 2, 2, 6, ]}
What is wrong?
Upvotes: 0
Views: 64
Reputation: 6581
If you use a list
instead of a dict
, as Xi_ suggested, then you can also do this:
import numpy as np
START_STAT =(
[ 4, 3, 6, 3, ],
[ 3, 3, 4, 6, ],
[ 3, 5, 5, 3, ],
[ 4, 6, 3, 3, ],
[ 4, 3, 6, 3, ],
[ 3, 3, 4, 6, ],
[ 3, 5, 5, 3, ],
[ 4, 6, 3, 3, ],
)
lst = ([ 6, 2, 2, 6, ])
np.vstack((START_STAT,lst))
Upvotes: 1
Reputation: 4687
START_STAT =(..)
Tuple is immutable
.
You could use list
for that purpose:
START_STAT = []
START_STAT.append([ 6, 2, 2, 6, ])
Upvotes: 2