E
E
EgaMen2016-01-21 13:38:53
Python
EgaMen, 2016-01-21 13:38:53

How to do it right in python programming?

2d1a768b75b84612afc07626848a4639.png748d21d0de234b4da10d930cca6d0321.png
I’m learning Python, but I can’t do this task (why is it wrong, how to do what would be right, how to convert a tuple to a string. I tried the replace and join functions too, I probably tried everything. but .. even do it for me, right now I’ll write the text of the task again (for those who don’t see the
sequence of lines in the picture. You must combine these lines into a block of text, separating the original lines with commas. As a joke on right-handed robots, you must replace all occurrences of the word "right" with the word "left", even if it is part of another word All strings are in lowercase
Input: Sequence of strings, as a tuple of strings (unicode)
Output: Text, as a string
Precondition:
0 < len(phrases) < 42

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
asd111, 2016-01-21
@EgaMen

def left_join(phrases):
    result = ",".join(phrases)
    result = result.replace('right', 'left')
    return result

V
Vladislav Sklyar, 2016-01-21
@VladSkliar

The tooltip says that you need to use the join function. Duck use it then use replace.

def left_join(phrases):
    str = ','
    return str.join(phrases).replace('rigth','left')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question