You do a really solid job explaining the different methods and what they do. A lot of university teachers aren’t even that proactive when they teach. I like how you explain each part of the code. This is quality content.
I can't figure out what to type to get my last print result thislist = ["apple", "banana", "cherry"] x = input("Enter your item:") thislist.insert(1, (x)) counter = Counter(thislist) print (counter.most_common()[0]) message = input("Enter your item:") if message == counter.most_common()[0]: print("you win")
You need to changed your second last line. Why? Because counter.most_common()[0] is returning a tuple with the element and its count. If you entered apple it would be ('apple', 2). Now to get the 'apple' string from this tuple which is what your program seems to be checking you need to get the first element from that tuple which can be done like this. if message == counter.most_common()[0][0]:
This guy is so underrated. Love your videos bro
You do a really solid job explaining the different methods and what they do. A lot of university teachers aren’t even that proactive when they teach. I like how you explain each part of the code. This is quality content.
why would you manually initialize a dictionary when you can use defaultdict(int)
Big 👍 like. Always a pleasure to watch your posts
I always used dictionary for counting. Find counter existence only last week and here is you video
How would you count without using total()?
What programme are you using? My Python looks different. I'm so lost.
What text editor do you use? I think he might be using VS Code with a theme.
Bro, you sound like Tech With Tim :D
The counter already orders elements by most occurrences to least. No need to use most_common
nice video!
This guy kind if looks like michael mando
continue codewars /clash of code please
First comment!!
I can't figure out what to type to get my last print result
thislist = ["apple", "banana", "cherry"]
x = input("Enter your item:")
thislist.insert(1, (x))
counter = Counter(thislist)
print (counter.most_common()[0])
message = input("Enter your item:")
if message == counter.most_common()[0]:
print("you win")
You need to changed your second last line. Why? Because counter.most_common()[0] is returning a tuple with the element and its count. If you entered apple it would be ('apple', 2). Now to get the 'apple' string from this tuple which is what your program seems to be checking you need to get the first element from that tuple which can be done like this.
if message == counter.most_common()[0][0]: