Vous êtes sur la page 1sur 1

26/09/2023 14:05 serie3 ex3.

py

1 #chaine tautogramme
2 from numpy import array
3 def nomber(ch) :
4 n=0
5 while len(ch)!=0 :
6 k=ch.find(" ")
7 ch=ch[k+1:]
8 n=n+1
9 return n
10
11 def verif(t):
12 ch=t[0]
13 c=ch[0]
14 res=True
15 i=0
16 while res and i<nomber(ch) :
17 ch1=t[i+1]
18 i=i+1
19 if ch1[0]!=c :
20 res=False
21 return res
22
23 def tautogramme(ch) :
24 n=nomber(ch)
25 t=array([str]*n)
26 i=0
27 k=ch.find(" ")
28 while k!=-1:
29 t[i]=ch[:k+1]
30 ch=ch[k+1:]
31 i=i+1
32 k=ch.find(" ")
33
34 if verif(t):
35 print("***la phrase tautogramme***")
36 else :
37 print("***la phrase n'est pas tautogramme***")
38
39 ch=input("donner une chaine : ")+" "
40 tautogramme(ch)

file:///C:/Users/jelas/AppData/Roaming/Thonny/temp/thonny_h9i34wu3.html 1/1

Vous aimerez peut-être aussi