Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sentence = input("Enter a Sentence : ")
- letter = input("Enter a letter : ")
- if letter in sentence:
- new_sentence = ""
- words = sentence.split()
- for i in words:
- if letter in i:
- new_sentence += i[::-1] + " "
- else:
- new_sentence += i + " "
- print("Modified Sentence : ", new_sentence)
- else:
- raise ValueError(f"The Letter {letter} does not exist in the Sentence")
- """
- Output:-
- Enter a Sentence : the quick brown fox jumps over the lazy dog
- Enter a letter : o
- Modified Sentence : the quick nworb xof jumps revo the lazy god
- >>>
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement