Python Forum
Quick Lists Question (Count Occurences)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quick Lists Question (Count Occurences)
#1
Good Evening,

I'm stuck in a headache and am looking to get some solutions. I've been given a problem that wants me to input 9 integers, and list the occurrences of those 9 integers. I've done it one way but the tool our class uses called 'Livelab' doesn't accept the code I gave it. For this purpose I will show both source code.


For the rejected code I used: 

from collections import Counter
a = [2, 5, 6, 5, 4, 3, 23, 43, 2]
print(Counter(a))
The code I'm working on currently looks like this. I've got some of the print statements to work within Idle, but am having trouble and the book I have has been little help.


for i in range(9):
   num_list = int(input("Enter integers between 1 and 100: "))
print(num_list.count(2))
print(num_list.count(5))
print(num_list.count(6))
print(num_list.count(4))
print(num_list.count(3))
print(num_list.count(23))
print(num_list.count(43))
Any help would be appreciated!
Reply


Messages In This Thread
Quick Lists Question (Count Occurences) - by EwH006 - Nov-16-2016, 12:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Count occurences in a string and add to a list using loops Leyo 4 1,692 Mar-11-2022, 03:52 PM
Last Post: Leyo
  Calculator I need quick help Malin3k 3 2,078 Feb-13-2021, 02:10 AM
Last Post: BashBedlam
  Count Letters in a Sentence (without using the Count Function) bhill 3 5,201 Jun-19-2018, 02:52 AM
Last Post: bhill
  regex, counting occurences yanhto 4 3,384 May-06-2018, 10:20 PM
Last Post: killerrex

Forum Jump:

User Panel Messages

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