Answer the question
In order to leave comments, you need to log in
Why doesn't if condition work in python?
When I run the code, for any value of a[i], count increases, tell me what is the problem?
a = input().split()
count = 0
for i in range(len(a)):
if a[i] == 'a' or 'an' or 'the':
count += 1
print(count)
Answer the question
In order to leave comments, you need to log in
if a[i] == 'a' or 'an' or 'the':
Because the comparison is only at the beginning a[i] == 'a'
The rest is like this
Write if a[i] in ['a','an','the']:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question