0
[Solved] Listing the output of list.count()
I have a list, and the output of list.count() is displayed on a new line for each item. Calling for list isn't working. How can I list the output? And how can I call for a specific line? P.S: It's multiple counts because I'm using a loop.
31 Réponses
+ 5
Phantom instead of printing, why do you not make a new list, and append to it ?
+ 4
Can you share your code ? Also, I didn't understand you question very well, can you give an example or two ?
+ 3
Phantom post your code please
+ 3
Which problem ? (advice: it's better to leave an empty line between some blocks for better readability)
EDIT: No need to answer, it's the military problem I think
+ 3
Maybe you missed this case:
12:00 AM will be 00:00, and not 12:00
Otherwise your code should be working
+ 3
Phantom did it work ?
+ 3
Phantom I only asked before I saw the error in your code.
1) You checked for m == "60", while you should be checking for m == "0"
2) You printed 1:00, you should print 01:00
+ 3
Phantom 12:60 doesn't not exist, the maximum you can get is 59, 12:60 will be 01:00AM, so you can just remove that case
+ 3
Hint:
When you get an input of 2:00 AM for example, your code outputs 2:00, but it should output 02:00
I just took a look at your code again, and this is the only thing you're still missing
+ 3
Phantom no problem
+ 2
Phantom no problem! If you have more questions, ask here, instead of making a new post
+ 2
I don't know, I don't use the code playground a lot, but I couldn't import num2words when I just tried.
Also, it is better not to use external modules too much, try to code it yourself first, you'll learn more
+ 2
Phantom that's not possible. I mean think about it, if you don't want to display the message, then how would others read it ? You can use input() for that, otherwise if you use input(Some text) and that text is not an empty character, then it will be displayed
+ 1
Another way to do,
[l.count(i) for i in l]
This will create the list.
+ 1
Done. Thx for pointing it out. Appreciate it.
Aymane Boukrouh
0
A list like this ["a","b","c"], but I'm using a for loop to count for each item. The output goes like this:
1
1
1
I need to list the output.
And is there a way to call for line(x), that would probably do it.
Aymane Boukrouh
0
I need to list it and then use max()
0
I'm just testing it. I will remove the print later. I just tried that and it worked. Thx a lot. Aymane Boukrouh
0
Ok. Aymane Boukrouh