+ 4
cant solve this
>>> letters=('p','t','z','j','u','elem') >>> if 'elem' in letters: ... letters.remove('elem') ... Traceback (most recent call last): File "<stdin>", line 2, in <module> AttributeError: 'tuple' object has no attribute 'remove'
4 Antworten
+ 13
The round brackets indicate that letters is a tuple, not a list. A tuple is immutable, so you can't remove items from it.
To declare a list, use letters=list(('p','t','z','j','u','elem')) or simply letters=['p','t','z','j','u','elem'].
+ 4
remove is the method for list not for tuple you are using in tuple.
letters=['p','t','z','j','u','elem']
if 'elem' in letters:
letters.remove('elem')
+ 1
tarok bro try using list ... not in tuple will produce error because u cannot change any values or removing it;)😎😎🌏Ty
0
the curve brackets indicate it's a type, change to block brackets and the work is done..