0

I'm trying to create a program in python that counts the number of words of a sentence inputted by a user by adding the number of spaces and full stops. The code I have written is:

sentence = raw_input('Enter your sentence')
word = 0

for i in sentence:
    if i == ' ' or '.':
        word += 1

print word

When I run the code it outputs the total number of characters. Can anyone spot my mistake?

T. Green
  • 323
  • 10
  • 20

0 Answers0