Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding -*- Utf-8 -*- #
- #find a word in a string function
- #---------------------------------#
- def contains_word(s, w):
- return (' ' + w + ' ') in (' ' + s + ' ')
- #---------------------------------#
- list_with_words_and_letters = []
- list_with_python = []
- line = str(input())
- while line != ".":
- # Checking if python in line
- if contains_word(line.lower(),"python") == True:
- list_with_words_and_letters.append(line) # appending the line in the list with words
- list_with_python.append("python") # appending python in list
- line = str(input())
- elif contains_word(line.lower(),"python") == False:
- list_with_words_and_letters.append(line) # appending the line in the list with words
- line = str(input())
- # If line is dot
- if line == ".":
- for words_and_letters in list_with_words_and_letters:
- 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