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.

30th Dec 2019, 9:02 AM
Issa
31 Respuestas
+ 5
Phantom instead of printing, why do you not make a new list, and append to it ?
30th Dec 2019, 9:11 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
Can you share your code ? Also, I didn't understand you question very well, can you give an example or two ?
30th Dec 2019, 9:04 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
Phantom post your code please
30th Dec 2019, 9:06 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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
30th Dec 2019, 11:45 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
Maybe you missed this case: 12:00 AM will be 00:00, and not 12:00 Otherwise your code should be working
30th Dec 2019, 11:58 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
Phantom did it work ?
30th Dec 2019, 1:07 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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
30th Dec 2019, 2:24 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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
30th Dec 2019, 2:29 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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
30th Dec 2019, 2:45 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
Phantom no problem
30th Dec 2019, 3:41 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
Phantom no problem! If you have more questions, ask here, instead of making a new post
30th Dec 2019, 9:14 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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
30th Dec 2019, 10:04 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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
30th Dec 2019, 7:56 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
Another way to do, [l.count(i) for i in l] This will create the list.
30th Dec 2019, 10:38 AM
Ankur Singh Oli
Ankur Singh Oli - avatar
+ 1
Done. Thx for pointing it out. Appreciate it. Aymane Boukrouh
30th Dec 2019, 3:41 PM
Issa
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
30th Dec 2019, 9:06 AM
Issa
0
I need to list it and then use max()
30th Dec 2019, 9:09 AM
Issa
0
I'm just testing it. I will remove the print later. I just tried that and it worked. Thx a lot. Aymane Boukrouh
30th Dec 2019, 9:13 AM
Issa
30th Dec 2019, 9:16 AM
Issa