So this is my code:
with open('cipher.txt') as f:
f = f.read().replace(' ', '')
new = []
for i in f:
new = sorted([i + ' ' + str(f.count(i)) for i in f])
for o in new:
print(o)
This is the text file:
xli uymgo fvsar jsb
It's supposed to get each letter used and print them before the amount of times they are used, in alphabetical order, but what I don't want is the letter 's' (or any letter that has a .count() of 2) will repeat twice, but i only want it to repeat once, how can I do this?
This is what i'm getting:
a 1
b 1
f 1
g 1
i 1
j 1
l 1
m 1
o 1
r 1
s 2
s 2
u 1
v 1
x 1
y 1
But this is what I want:
a 1
b 1
f 1
g 1
i 1
j 1
l 1
m 1
o 1
r 1
s 2
u 1
v 1
x 1
y 1