Skip to content

Commit d23bbfd

Browse files
committed
add yoda translator
add the script to the projects list add requirements
1 parent 18fee78 commit d23bbfd

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ So far, the following projects have been integrated to this repo:
6161
|[CLI Calculator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/cli_calculator)|[Willian GL](https://github.com/williangl) |
6262
|[Find PhoneNumber in String](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Find-PhoneNumber-in-String)|[Austin Zuniga](https://github.com/AustinZuniga)|
6363
|[IMDB TV Series Info Extractor](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/imdb_episode_ratings)|[Yash Raj Sarrof](https://github.com/yashYRS) |
64+
|[Yoda-speak Translator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/speak_like_yoda)|[sonniki](https://github.com/sonniki) |
6465

6566
## How to use :
6667

speak_like_yoda/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Speak-Like-Yoda
2+
3+
## Description
4+
A python script that translates an input English sentence into Yoda-speak.
5+
6+
## Usage
7+
Run ```python speak_like_yoda.py```. Type in your sentence to get it translated into Yoda-speak.
8+
9+
## Requirements
10+
The script only uses Python's standard modules ```random``` and ```string```, so no additional installation is needed.

speak_like_yoda/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
random
2+
string

speak_like_yoda/speak_like_yoda.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import random
2+
import string
3+
4+
def speak_like_yoda(sentence):
5+
"""
6+
Translate the input sentence into Yoda-speak.
7+
8+
:param sentence: input string
9+
:return: translation to Yoda-speak
10+
"""
11+
sentence = sentence.lower()
12+
for p in string.punctuation.replace("'", ''):
13+
sentence = sentence.replace(p, '')
14+
words = sentence.split()
15+
random.shuffle(words)
16+
new_sent = ' '.join(words)
17+
print()
18+
print('Your Yodenglish sentence:')
19+
print(new_sent.capitalize())
20+
21+
if __name__ == '__main__':
22+
print('Your English sentence:')
23+
sentence = str(input())
24+
speak_like_yoda(sentence)

0 commit comments

Comments
 (0)