פייתון/פייתון גרסה 3/מילון: הבדלים בין גרסאות בדף

תוכן שנמחק תוכן שנוסף
שורה 76:
להרחיב.
 
השוואה בין שני טקסטים
<source lang="python">
#from string to list
str1 = "ABC NCD DFS DSF TPY SDR"
str2 = "NKS MKS DSO SDR SDU DFH"
 
L1=str1.split(' ')
L2=str2.split(' ')
 
#creats sets
S1=set(L1)
s2=set(L2)
 
#range of the list
print(range(len(L1)))
 
for i in range(len(L1)):
print(i)
 
#creat dict for a word
seqalign=[]
 
for i in range(len(L1)):
if L1[i] == L2[i]:
seqalign.append(L1)
else:
seqalign.append("~~~")
print(L1)
print(L2)
 
#words in both list
print(seqalign)
range(0, 6)
0
1
2
3
4
5
['ABC', 'NCD', 'DFS', 'DSF', 'TPY', 'SDR']
['NKS', 'MKS', 'DSO', 'SDR', 'SDU', 'DFH']
['~~~', '~~~', '~~~', '~~~', '~~~', '~~~']
</source>
 
===ראה===