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
RE: python use of <> - by metulburr - Nov-16-2016, 02:36 AM
RE: python use of <> - by Skaperen - Nov-16-2016, 03:01 AM
RE: python use of <> - by nilamo - Nov-16-2016, 02:59 PM
RE: python use of <> - by Larz60+ - Nov-16-2016, 07:45 AM
RE: python use of <> - by Larz60+ - Nov-16-2016, 04:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Row Count and coloumn count Yegor123 4 2,956 Oct-18-2022, 03:52 AM
Last Post: Yegor123
  Quick question/help regarding my variable Extra 5 2,677 May-06-2022, 12:01 AM
Last Post: Extra
  Quick Question about Dictionaries Extra 6 3,003 Apr-29-2022, 08:34 PM
Last Post: Extra
  Filtering a data frame according to number of occurences of an observation Menthix 1 2,460 May-31-2021, 10:50 PM
Last Post: supuflounder
  Noob question about lists adifrank 4 3,884 Nov-19-2020, 03:26 AM
Last Post: adifrank
  beginner question about lists and functions sudonym3 5 4,078 Oct-17-2020, 12:31 AM
Last Post: perfringo
  Split dict of lists into smaller dicts of lists. pcs3rd 3 3,415 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  quick question/excel+python zarize 1 2,919 Dec-06-2019, 05:38 PM
Last Post: Larz60+
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 5,335 Mar-20-2019, 08:01 PM
Last Post: stillsen
  A quick question teczone 4 4,058 Sep-06-2018, 03:44 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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