Advertisement
Guest User

w o l v e s

a guest
Jan 18th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. # -*- coding -*- Utf-8 -*- #
  2.  
  3. #find a word in a string function
  4.  
  5. #---------------------------------#
  6. def contains_word(s, w):
  7.     return (' ' + w + ' ') in (' ' + s + ' ')
  8. #---------------------------------#
  9.  
  10. list_with_words_and_letters = []
  11. list_with_python = []
  12. line = str(input())
  13.  
  14. while line != ".":
  15.     # Checking if python in line
  16.  
  17.     if contains_word(line.lower(),"python") == True:
  18.  
  19.         list_with_words_and_letters.append(line) # appending the line in the list with words
  20.         list_with_python.append("python")  # appending python in list
  21.  
  22.         line = str(input())
  23.  
  24.     elif contains_word(line.lower(),"python") == False:
  25.         list_with_words_and_letters.append(line)  # appending the line in the list with words
  26.         line = str(input())
  27.  
  28.     # If line is dot
  29.     if line == ".":
  30.         for words_and_letters in list_with_words_and_letters:
  31.             print(words_and_letters[list_with_python.count("python") - 1],end=" ")  # printing letters of the line[count python]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement