I need to put this in a 1d list/ array using python. And then add them together. what im trying to do is find out how many letters are repeated and add about 4 letters and how much they are repeated( for example how many times letters A to E were repeated. And to do that i need to put it into lists/arrays. Thank you:) The results should show the sum of the grouped letters. ** Example:
Letters A to E has been repeated 45 times
# Input
fin = open("inputFileAssig.txt", "r")
lines = fin.readlines()
sort = sorted(lines)
joined = ''.join(sort)
fin.close()
# Processing
# A to E
a = joined.count("A")
b = joined.count("B")
c = joined.count("C")
d = joined.count("D")
e = joined.count("E")
# F to J
f = joined.count("F")
g = joined.count("G")
h = joined.count("H")
i = joined.count("I")
j = joined.count("J")
# K to O
k = joined.count("K")
l = joined.count("L")
m = joined.count("M")
n = joined.count("N")
o = joined.count("O")
# P to T
p = joined.count("P")
q = joined.count("Q")
r = joined.count("R")
s = joined.count("S")
t = joined.count("T")
# U to Z
u = joined.count("U")
v = joined.count("V")
w = joined.count("W")
x = joined.count("X")
y = joined.count("Y")
z = joined.count("Z")
# Results
comboAtoE = a + b + c + d + e
print("The letters from A to E repeats", comboAtoE, "times.")
comboFtoJ = f + g + h + i + j
print("The letters from F to J repeats", comboFtoJ, "times.")
comboKtoO = k + l + m + n + o
print("The letters from K to O repeats", comboKtoO, "times.")
comboPtoT = p + q + r + s + t
print("The letters from P to T repeats", comboPtoT, "times.")
comboUtoZ = u + v + w + x + y + z
print("The letters from U to Z repeats", comboUtoZ, "times.")
total = comboAtoE + comboFtoJ + comboKtoO + comboPtoT + comboUtoZ
print("And in total there are", total, "letters in the file.")