-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRightToLeft.py
More file actions
37 lines (22 loc) · 1019 Bytes
/
RightToLeft.py
File metadata and controls
37 lines (22 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
''' One of the robots is charged with a simple task:
to join a sequence of strings into one sentence to produce instructions on how to get around the ship.
But this robot is left-handed and has a tendency to joke around and confuse its right-handed friends.
You are given a sequence of strings.
You should join these strings into a chunk of text where the initial strings are separated by commas.
As a joke on the right handed robots, you should replace all cases of the words "right" with the word "left",
even if it's a part of another word. All strings are given in lowercase.
Input: A sequence of strings.
Output: The text as a comma-separated string.
Precondition:
0 < len(phrases) < 42 '''
#def left_join(phrases: tuple) -> str:
phrases = ("left", "right", "left", "stop")
temp = ""
for element in phrases:
temp = temp+ element.replace("right","left")
temp = temp + ","
print(temp)
temp=temp.rstrip(",")
print(temp)
print(phrases)
#return temp