mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-12-18 08:10:17 +00:00
d23bbfdcf0
add the script to the projects list add requirements
25 lines
650 B
Python
25 lines
650 B
Python
import random
|
|
import string
|
|
|
|
def speak_like_yoda(sentence):
|
|
"""
|
|
Translate the input sentence into Yoda-speak.
|
|
|
|
:param sentence: input string
|
|
:return: translation to Yoda-speak
|
|
"""
|
|
sentence = sentence.lower()
|
|
for p in string.punctuation.replace("'", ''):
|
|
sentence = sentence.replace(p, '')
|
|
words = sentence.split()
|
|
random.shuffle(words)
|
|
new_sent = ' '.join(words)
|
|
print()
|
|
print('Your Yodenglish sentence:')
|
|
print(new_sent.capitalize())
|
|
|
|
if __name__ == '__main__':
|
|
print('Your English sentence:')
|
|
sentence = str(input())
|
|
speak_like_yoda(sentence)
|