Python Forum

Full Version: homework
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How would i remove triplets from a list
so for example
[1,1,1,2,4,5,7,7,7]
would become
[2,4,5]
You can use count() method to count how many times element appears in a list in a Loop For.
I cant use count() METHOD i can use append() pop() sum() index()
Start with an empty list. Loop through the list of numbers, counting how many times the number appears. If you get to a new number without the previous number being a triple, append the previous number to the new list.
(May-13-2019, 03:00 PM)sheck33332 Wrote: [ -> ]I cant use count() METHOD i can use append() pop() sum() index()
To get as much help as possible, please post full text of your assignment and any restrictions that you have. Then post your code in python tags, full traceback for any error that you get - in error tags. Ask specific questions.
(May-13-2019, 01:40 PM)Vimart Wrote: [ -> ]You can use count() method to count how many times element appears in a list in a Loop For.
A bit of an aside - performance almost certainly doesn't matter for the homework, but using count() would likely have serious performance issues.