fork download
  1. #This is my PYTHON program
  2. n=70;
  3. array = [''] * 70;
  4. s=i=k=int();
  5. print("Please enter string (up to 70 characters):");
  6. while i<n:
  7. s=input("Enter character: ");
  8. if s == '':
  9. break;
  10. array[i]=s;
  11. i=i+1;
  12. print("My string was:");
  13. for i in range(0, n, 1):
  14. print(array[i], end='');
  15. print();
  16. if array[0]!=' ' and array[1]!=' ' and array[2]!=' ' and array[3]!=' ' and array[4]==' ':
  17. k=k+1;
  18. for i in range (0,n-5,1):
  19. if array[i]==' ' and array[i+1]!=' ' and array[i+2]!=' ' and array[i+3]!=' ' and array[i+4]!=' ' and array[i+5]==' ':
  20. k=k+1;
  21. if array[65]==' ' and array[66]!=' ' and array[67]!=' ' and array[68]!=' ' and array[69]!=' ':
  22. k=k+1;
  23. print("Number of 4-letter words:", k);
Success #stdin #stdout 0.08s 14152KB
stdin
E
a
c
h 
 

c
o
d
e 

p
a
r
t 

m
u
s
t 

w
o
r
k

f
i
n
e 

o
r 

b
u
g
s 

w
i
l
l 

s
t
o
p

t
h
e 

f
l
o
w
stdout
Please enter string (up to 70 characters):
Enter character: Enter character: Enter character: Enter character: Enter character: Enter character: My string was:
Each  
Number of 4-letter words: 1