-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
38 lines (28 loc) · 763 Bytes
/
Copy pathtest.py
File metadata and controls
38 lines (28 loc) · 763 Bytes
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
import string
import argparse, math, os, re, string, zipfile
from typing import DefaultDict, Generator, Hashable, Iterable, List, Sequence, Tuple
from collections import defaultdict
f_1 = open("words.txt", "r")
f_2 = open("dict.txt", "r")
dict_1 = defaultdict(lambda: defaultdict(list))
lines_1 = f_1.readlines()
lines_2 = f_2.readlines()
for line in lines_1:
first = line[0]
second = ' '
if len(line) >= 2:
second = line[1]
dict_1[first][second].append(line)
for line in lines_2:
first = line[0]
second = ' '
if len(line) >= 2:
second = line[1]
if line not in dict_1[first][second]:
dict_1[first][second].append(line)
f_1.close()
f_2.close()
f_3 = open("new.txt", "w")
for x in dict_1:
for y in dict_1[x]:
f_3.writelines(dict_1[x][y])