This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
NG_2022_Stanislav_Mykhailenko/Lesson_3/task3.py
Stanislav Mykhailenko ce6f17c445
Add Lesson 3 Task 3
2022-11-03 19:41:32 +02:00

37 lines
1.9 KiB
Python

# Lesson 3 Task 3: calculate a number of each letter occurences in a string without using loops
# Author: Stanislav Mykhailenko
# License: Unlicense
# Return codes:
# 0 - OK
occurences = {}
string = input("Enter a string: ")
if (string.count("A")): print("A - " + str(string.count("A")))
if (string.count("B")): print("B - " + str(string.count("B")))
if (string.count("C")): print("C - " + str(string.count("C")))
if (string.count("D")): print("D - " + str(string.count("D")))
if (string.count("E")): print("E - " + str(string.count("E")))
if (string.count("F")): print("F - " + str(string.count("F")))
if (string.count("G")): print("G - " + str(string.count("G")))
if (string.count("H")): print("H - " + str(string.count("H")))
if (string.count("I")): print("I - " + str(string.count("I")))
if (string.count("J")): print("J - " + str(string.count("J")))
if (string.count("K")): print("K - " + str(string.count("K")))
if (string.count("L")): print("L - " + str(string.count("L")))
if (string.count("M")): print("M - " + str(string.count("M")))
if (string.count("N")): print("N - " + str(string.count("N")))
if (string.count("O")): print("O - " + str(string.count("O")))
if (string.count("P")): print("P - " + str(string.count("P")))
if (string.count("Q")): print("Q - " + str(string.count("Q")))
if (string.count("R")): print("R - " + str(string.count("R")))
if (string.count("S")): print("S - " + str(string.count("S")))
if (string.count("T")): print("T - " + str(string.count("T")))
if (string.count("U")): print("U - " + str(string.count("U")))
if (string.count("V")): print("V - " + str(string.count("V")))
if (string.count("W")): print("W - " + str(string.count("W")))
if (string.count("X")): print("X - " + str(string.count("X")))
if (string.count("Y")): print("Y - " + str(string.count("Y")))
if (string.count("Z")): print("Z - " + str(string.count("Z")))
# and so on for each allowed Unicode character