Awesome-Python-Scripts/speak_like_yoda/speak_like_yoda.py
sonniki d23bbfdcf0 add yoda translator
add the script to the projects list

add requirements
2019-10-07 09:03:12 +02:00

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)