I have a coding assignment where I need to create a program that checks for the number of times a dictionary of names have the letters R, M, A, K and C. So in this case I have this dictionary:
dict = {"Renata", "Maciek", "Marek", "Karolina", "Marcel}
I need to create a loop that checks for all of those letters in all of the names in the dictionary one by one. Once it is done, it needs to put the results in a list and return the list at the end of the program. So the result will look like
R - 4 M - 2 A - 3. (numbers are just to give an example) K - 5 C - 6
This is what I have so far:
names = {"Renata", "Marek", "Maciek", "Karolina", "Marcel"}
letter = ['R', 'M', 'A', 'K', 'C']
counter = 0
for letter in names:
print("R =", names.count("R"))
print("M =", names.count("M"))
print("A =", names.count("A"))
print("K =", names.count("K"))
print("C = ", names.count("C"))
I am very new to Python as you can see so I would greatly appreciate some input or help. Please show the changes that you make to the code. Thank you in advance