File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
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.
11
+
12
+ ## Output
13
+ ```
14
+ Your English sentence:
15
+ Avoiding failure is something we learn at some later point in life.
16
+
17
+ Your Yodenglish sentence:
18
+ Something is we point some failure learn avoiding later at in life
19
+
20
+ ```
21
+
22
+ ## Author(s)
23
+
24
+ [ Soumik Kumar Baithalu] ( https://www.github.com/soumik2012 )
Original file line number Diff line number Diff line change
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 ('\n Your Yodenglish sentence: ' )
18
+ print (new_sent .capitalize ())
19
+
20
+ if __name__ == '__main__' :
21
+ print ('Your English sentence: ' )
22
+ sentence = str (input ())
23
+ speak_like_yoda (sentence )
Original file line number Diff line number Diff line change
1
+ random
2
+ string
You can’t perform that action at this time.
0 commit comments