Add Lesson 3 Task 3
This commit is contained in:
parent
ea949f4325
commit
ce6f17c445
1 changed files with 37 additions and 0 deletions
37
Lesson_3/task3.py
Normal file
37
Lesson_3/task3.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
# 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
|
Reference in a new issue