I'm following along in a tutorial book and this program is supposed to count the spaces in a sentence to tell how many words there are. I am not getting anywhere close to the number of words I type, any suggestions? also when I go to run the program in python I keep getting these error messages when I submit: python word_count1.py. However, if I type: python word_count1 without the .py it runs the program, but this is when the answer is way off. any advice?
line = input()
total_words = line.count(' ') + 1
print(total_words)
PS C:\Users\mattr\OneDrive\Desktop\python_problems> python word_count1.py
C:\Users\mattr\AppData\Local\Microsoft\WindowsApps\python.exe: can't open file 'C:\\Users\\mattr\\OneDrive\\Desktop\\python_problems\\word_count1.py': [Errno 2] No such file or directory
PS C:\Users\mattr\OneDrive\Desktop\python_problems> python word_count
I love the United States
26
PS C:\Users\mattr\OneDrive\Desktop\python_problems> python word_count.py
C:\Users\mattr\AppData\Local\Microsoft\WindowsApps\python.exe: can't open file 'C:\\Users\\mattr\\OneDrive\\Desktop\\python_problems\\word_count.py': [Errno 2] No such file or directory