Advertisement
ssoni

stringstuff.py

Oct 24th, 2023
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. phrase = input("Enter any phrase: ").lower()
  2. phrase = phrase.replace('camaro', 'Mustang')
  3. searchterm = input('What do you want to search for? ').lower()
  4.  
  5. x = phrase.count(searchterm)
  6. phrase = phrase.capitalize()
  7.  
  8. if x==1:
  9.     word = 'time'
  10. else:
  11.     word = 'times'
  12.  
  13. print(f'The word \'{searchterm}\' appears {x} {word} in the phrase, \'{phrase}\'.')
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement