Hi? i'm new at programming and im trying to decipher a code. i'm trying to count how many times a char occurs in txt file

File = open('path\\to\\file', 'rb')
Data = File.read()
File.close()

Data.count('aChar')

Thanks.. i got it another way.. i converted the string into ascii values then saved them into a list.
i then used a list.count(i) to see how many times a certain value occurred.. thanks again

to find the letter that occurs the most you can do:

File = open("path", "rb")
txt = File.read()
File.close()

mode = max(txt, key=txt.count)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.