info_outline

Solutions will be available when this assignment is resolved, or after a few failing attempts.

Positions

Write a function positions that receives a string and 3 words, and gives you the positions of those words in the original string. Example:

# Positions:
#         0                         26      34
phrase = "Python is good. Python is Wise. I like Python"
positions(phrase, 'Python', 'Wise', 'like')  # "0,26,34"

If the word doesn't exist in the original string, it should backfill using dashes. Example:

# Positions:
#         0                         26
phrase = "Python is good. Python is Wise. I like Python"
positions(phrase, 'Python', 'Wise', 'Ruby')  # "0,26,-" (Ruby doesn't exist)

Test Cases

test one occurrence third word - Run Test

def test_one_occurrence_third_word():
    # Positions:
    #         0                         26      34
    phrase = "Python is good. Python is Wise. I like Python"
    assert positions(phrase, 'Javscript', 'Ruby', 'Wise') == "-,-,26"

test two occurrences missing first - Run Test

def test_two_occurrences_missing_first():
    # Positions:
    #         0                         26      34
    phrase = "Python is good. Python is Wise. I like Python"
    assert positions(phrase, 'Ruby', 'Wise', 'like') == "-,26,34"

test two occurrences missing third - Run Test

def test_two_occurrences_missing_third():
    # Positions:
    #         0                         26      34
    phrase = "Python is good. Python is Wise. I like Python"
    assert positions(phrase, 'Python', 'Wise', 'Ruby') == "0,26,-"

test one occurrence first word - Run Test

def test_one_occurrence_first_word():
    # Positions:
    #         0                         26      34
    phrase = "Python is good. Python is Wise. I like Python"
    assert positions(phrase, 'Python', 'Javascript', 'Ruby') == "0,-,-"

test three occurrences - Run Test

def test_three_occurrences():
    # Positions:
    #         0                         26      34
    phrase = "Python is good. Python is Wise. I like Python"
    assert positions(phrase, 'Python', 'Wise', 'like') == "0,26,34"

test one occurrence second word - Run Test

def test_one_occurrence_second_word():
    # Positions:
    #         0                         26      34
    phrase = "Python is good. Python is Wise. I like Python"
    assert positions(phrase, 'Javscript', 'like', 'Ruby') == "-,34,-"
def positions(a_string, first_word, second_word, third_word): pass