Skip to content
Snippets Groups Projects
Commit ed3ad4d9 authored by Dahmane Lynda's avatar Dahmane Lynda
Browse files

suite anagrammes

parent 50fa6fa9
No related branches found
No related tags found
No related merge requests found
......@@ -36,11 +36,11 @@
#>>>"!".join(s)
#"la méthode split est parfois bien utile"
#>>>"".join()
#"la méthode split est parfois bien utile"
#(" ")
#>>>"".join([])
#[]
#>>>"".join([1,2])
#"la méthode split est parfois bien utile"
#"12"
#Question 2:
# La methode join est utiliseé pour joindre les éléments d'une liste en une suele chaine de caractères
......@@ -57,7 +57,7 @@
# """renvoie une nouvelle chaine de caractéres en concaténant les élement de
# l en les intercalant avec s.
#
# Précondition :
crypto# Précondition :
# Exemple(s) :
# $$$ join('.', ['raymond', 'calbuth', 'ronchin', 'fr'])
# 'raymond.calbuth.ronchin.fr'
......@@ -128,20 +128,40 @@ def sont_anagrammes(s1: str, s2: str) -> bool:
True
$$$ sont_anagrammes('orange','Organe')
False
"""
res=dict()
d=dict()
for elt in s1:
if elt in res:
dict1=dict()
dict2=dict()
for elt in s1:
if elt in dict1:
dect1[elt]=dict1[elt]+1
else:
dict1[elt]=1
for elt in s2:
if elt in dict2:
dect2[elt]=dict2[elt]+1
else:
dict2[elt]=1
d1,d2=list(dict1),list(dict2)
d1.sort(),d2.sort()
return d1==d2
#question 3:
def sont_anagrammes(s1: str, s2: str) -> bool:
"""Renvoie True si s1 et s2 sont anagrammatiques, False sinon
Précondition : aucune
Exemple(s) :
$$$ sont_anagrammes('orange', 'organe')
True
$$$ sont_anagrammes('orange','Organe')
False
$$$ sont_anagrammes('orange','OrganE')
False
"""
res=False
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment