-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_python1.py
More file actions
25 lines (18 loc) · 829 Bytes
/
test_python1.py
File metadata and controls
25 lines (18 loc) · 829 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
import urllib.request
# url= urllib.request.urlopen("https://gist.githubusercontent.com/calvinmetcalf/084ab003b295ee70c8fc/raw/314abfdc74b50f45f3dbbfa169892eff08f940f2/wordlist.txt")
# txt = url.read()
# type(txt)
# x=txt.split()
liste1=['chien','chine','niche','race','poire','proie']
def anagramme (liste):
liste_anagramme=[]
for i in range(len(liste)):
for j in range(len(liste)-i):
if sorted(liste[i]) == sorted(liste[j+i]) and liste[i]!= liste[j+i]:
#print(liste[i], ';', liste[j+i])
liste_anagramme.append((liste[i])+(' ')+(liste[j+i]))
liste_anagramme= sorted(liste_anagramme)
print(liste_anagramme)
return liste_anagramme
def test_anagramme():
assert anagramme(liste1)== ['chien chine', 'chien niche', 'chine niche', 'poire proie']