I have three lists, let's call them List1, List2, and List3.
Lists 1 and 2 are received by the function as arguments, and List3 is created in the function.
I'm trying to take List1 and count how many times each unique element within it appears, and display those numbers next to a list of only those unique elements, without duplicates, in the order that the first instance of that element appeared in List1.
The breakdown: List1 contains many elements, with some duplicates. List2 contains a unique set of elements from List1, in the order they appeared first in List1. List3 contains the number of times each unique element in List2 appeared in List1, next to the unique element the number corresponds to in List2.
Below is the way I tried to accomplish this, but I'm missing something. I may just be off my rocker completely on the coding. Please let me know how I can accomplish this task. Thank you!
def successfulTrials(List1, List2):
List3 =[y]
for x in List1:
y = List1.count(i) for i in List2
for z in List3:
z.extend([i])
print(z)
People have asked for an example of the lists: List1 = ['Jan', 'Feb', 'Aug', 'Mar', 'Jan', 'Apr', 'May', 'Sep', 'Jun', 'Jan', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Jan', 'Dec']
List2 = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
A display of List3 would look like: 4 Jan 1 Feb 2 Aug 1 Mar 1 Apr 1 May 2 Sep 1 Jun 1 Jul 1 Oct 1 Nov 1 Dec