Advertisement
Guest User

word count

a guest
Apr 4th, 2020
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. def profile():
  2.     profile = input("Write something about yourself - max. 10 words\n")
  3.     word_count = 0
  4.     for word in profile:
  5.         if word != " ":
  6.             continue
  7.         else:
  8.             word_count = word_count + 1
  9.     word_count = word_count + 1
  10.     return word_count
  11.  
  12. word_count = profile()
  13.  
  14. while word_count > 10:
  15.     print("I'm sorry, those are " + str(word_count) + " words. The maximum is 10 words.")
  16.     profile()
  17.     word_count = profile()
  18.     if word_count <= 10:
  19.         print("Alright, those are " + str(word_count) + " words. You can post it!")
  20.         break
  21. else:
  22.     word_count <= 10
  23.     print("Alright, those are " + str(word_count) + " words. You can post it!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement