-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaba1.py
41 lines (35 loc) · 866 Bytes
/
laba1.py
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
import string
import json
f = open('pokemon_full.json')
s = f.read()
jsn = json.loads(s)
#########task1#########
print('Task1:')
print(len(s))
#########task2#########
print('Task2:')
temp1 = s.translate(s.maketrans(dict.fromkeys(string.punctuation)))
temp2 = len(temp1.replace(' ', ''))
print(temp2)
#########task3#########
print('Task3:')
s = ''
name = ''
for obj in jsn:
if len(obj['description']) > len(s):
s = obj['description']
name = obj['name']
print(name)
#########task4#########
print('Task4:')
words_num = 0
abilities = []
for obj in jsn:
for abil in obj['abilities']:
if len(abil.split()) > words_num:
words_num = len(abil.split())
abilities = []
if len(abil.split()) == words_num:
abilities.append(abil)
print(abilities)
f.close()