+ 1

based on letters.remove() syntax

when this code is run only 1st 'p' is removed what should be done to remove 4th 'p' and not the 1st. letters= ['p', 'q', 'r', 'p', 's', 't'] letters.remove('p') print(letters)

2nd Apr 2020, 7:41 AM
Ansh
1 Antwort
+ 4
This should remove the second occurance of a letter: letters= ['p', 'q', 'r', 'p', 's', 't'] print(letters) del letters[letters.index('p',1)] print(letters)
2nd Apr 2020, 12:30 PM
Lothar
Lothar - avatar