Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ---------------------------------
- # СТАТИСТИКА СИМВОЛОВ В ТЕКСТЕ
- # ВЫПОЛНИЛ: ДМИТРИЙ МИШУТИН, КЭ - 101
- # ---------------------------------
- inp = open("input.txt", "r")
- out = open("output.txt", "w")
- letters = 0
- digits = 0
- chars = 0
- arr = list(inp.read())
- for i in range(len(arr)):
- if ord("A") <= ord(arr[i]) <= ord("Z") or ord("a") <= ord(arr[i]) <= ord("z"):
- letters += 1
- if ord("0") <= ord(arr[i]) <= ord("9"):
- digits += 1
- if arr[i] in [".", ",", "?", "!"]:
- chars += 1
- out.write("Count of letters: " + str(letters) + "\n")
- out.write("Count of digits: " + str(digits) + "\n")
- out.write("Count of punctuation marks: " + str(chars) + "\n")
- inp.close()
- out.close()
Add Comment
Please, Sign In to add comment