diff --git a/README.md b/README.md index d6049ae..e9ed08d 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ So far, the following projects have been integrated to this repo: |[CLI Calculator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/cli_calculator)|[Willian GL](https://github.com/williangl) | |[Find PhoneNumber in String](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Find-PhoneNumber-in-String)|[Austin Zuniga](https://github.com/AustinZuniga)| |[IMDB TV Series Info Extractor](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/imdb_episode_ratings)|[Yash Raj Sarrof](https://github.com/yashYRS) | +|[Yoda-speak Translator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/speak_like_yoda)|[sonniki](https://github.com/sonniki) | ## How to use : diff --git a/speak_like_yoda/README.md b/speak_like_yoda/README.md new file mode 100644 index 0000000..dedbacf --- /dev/null +++ b/speak_like_yoda/README.md @@ -0,0 +1,10 @@ +# Speak-Like-Yoda + +## Description +A python script that translates an input English sentence into Yoda-speak. + +## Usage +Run ```python speak_like_yoda.py```. Type in your sentence to get it translated into Yoda-speak. + +## Requirements +The script only uses Python's standard modules ```random``` and ```string```, so no additional installation is needed. \ No newline at end of file diff --git a/speak_like_yoda/requirements.txt b/speak_like_yoda/requirements.txt new file mode 100644 index 0000000..733226a --- /dev/null +++ b/speak_like_yoda/requirements.txt @@ -0,0 +1,2 @@ +random +string \ No newline at end of file diff --git a/speak_like_yoda/speak_like_yoda.py b/speak_like_yoda/speak_like_yoda.py new file mode 100644 index 0000000..09a36c6 --- /dev/null +++ b/speak_like_yoda/speak_like_yoda.py @@ -0,0 +1,24 @@ +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)