count - python: How to read occurrences of character in file -
i want display how many occurrences there of each letter in text-file.
f=file.read() in f: if str(i) == '\n': pass else: print("there ",f.count(i),str(i),"'s in text.")
this not n duplicates of text n occurrences of symbol. should do?
thanks!
i found solution worked task had:
x=0 while x<10000: ## or sufficiently high number if chr(x) == "\n": x+=1 elif chr(x) in somefile: print("there ", f.count(chr(x)), chr(x),"'s in text.") x+=1 else: x+=1
python count
No comments:
Post a Comment