Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
homework
#1
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]
Reply
#2
You can use count() method to count how many times element appears in a list in a Loop For.
Reply
#3
I cant use count() METHOD i can use append() pop() sum() index()
Reply
#4
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
(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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
(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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020