This is a program to count the number of times the letter "o" appears in a sentence.
sentence = "We hold these truths to be self-evident..."
number_of_Os = 0
for i in sentence:
if i == "o":
number_of_Os += 1
print(number_of_Os)
This program works, but it only counts lowercase. I want to count BOTH uppercase AND lowercase.
So I changed this line:
if i == "o":
to this:
if i == "o" or "O":
sentence = "We hold these truths to be self-evident..."
number_of_Os = 0
for i in sentence:
if i == "o" or "O":
number_of_Os += 1
print(number_of_Os)
The second program counts EVERY character in the string, not just the o's.
Why does it do this?