-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab_2.py
More file actions
44 lines (41 loc) · 1.73 KB
/
Copy pathLab_2.py
File metadata and controls
44 lines (41 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from itertools import count
choice = input("""Виберіть ваш варіант:
A - Кількість букв в тексті
B - Сортувати за абеткою
Ваш вибір : """)
def countstr(leter):
d = {}
for w in leter:
d[w] = leter.count(w)
for k in sorted(d):
print(k + ":" + str(d[k]))
while choice == "A":
print("Ви обрали операцію 'A' (Обрахувати кількість кожної букви у тексті )")
ttx = (input("""Введіть ваш текст :
""")).strip()
countstr(ttx)
print("Програма виконана! ")
print("Якщо бажаєте продовжити натисніть - 1")
print("Вихід - 2")
choice2 = input("Ваша операція : ")
if choice2 =="2":
break
if choice2 == "1":
choice == "A"
else: print("Довбню, ти зламав програму!!! ")
while choice == "B":
print("Ви обрали опрерацію 'B' (Посортувати слова в словниковому порядку)")
ttx = input("""Введіть ваш текст :
""").replace('%', '').replace('$', '').replace('@', '').replace('*', '').replace('.', '').replace('!', '').replace('&', '').replace('#','').replace(';','').replace('(','').replace(')','')
ttx = ttx
ttx = sorted(ttx)
print(ttx)
print("Програма виконана!")
print("Якщо бажаєте продовжити натисніть - 1")
print("Вихід - 2")
choice3 = input("Ваша операція : ")
if choice3 =="2":
break
if choice3 == "1":
choice == "B"
else: print("Довбню, ти зламав програму!!! ")