#๐ I have no clue what the problem is please tell me
21 messages ยท Page 1 of 1 (latest)
@gray pulsar
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
What is the problem statement?
Your code sums the elements in the list accurately so you might be misunderstanding the problem statement.
It says unique - do you need to ignore the duplicates?
That's what I thought, but then the answer would be 6
no the answer would be 5
Ah, non-unique numbers aren't included at all.
No worries, you missed the sentence. Happens. Always read the problem statement carefully.
I thought they;d expect them to just be de-duplicated.
actually happens quite a bit in programming competitions
The questions are even worded to be tricky so you need to pay close attention.
@gray pulsar Are you able to solve it now?
I'd maybe use Counter to do an initial count, then iterate the counter and only use numbers that have a count of 1.
But yes, -= is an operator.
from collections import Counter
It's a special type of dictionary that counts the elements you give it.
You could also just do the same with a loop and normal dictionary.
You'd have to count them first to know the amounts.
Or a dictionary that you make yourself. Learning how to count elements in a list using a dictionary would be a good exercise on its own.
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.