dimanche 23 avril 2017

What is the difference between codes in line 4 in the following two programs? The first one prints 5 but the second one prints 15

s = "azcbobobegghakl"
count = 0
for char in s:
    if char == 'a' or char== 'e' or char== 'i' or char== 'o' or char== 'u':
        count += 1
print count


s = "azcbobobegghakl"
count = 0
for char in s:
    if char == 'a' or 'e' or 'i' or 'o' or 'u':
        count += 1
print count

Aucun commentaire:

Enregistrer un commentaire