House Exercise!

Hi, I have doubts like it make the house exercise. I don’t understand like begin and use the parameters. for example, when I finish of iteration or it need a logical or sintaxis to build the new phrases. Any can I help me, please?

def recite(start_verse, end_verse):
“”" start_verse: frase inicial o frase a incrustar.
end_verse: frase final con incrutsacion.
“”"
if “{frase}” not in start_verse:
return start_verse

""" Incrustar la frase dentro de la frase principal. """
   start_verse = start_verse.replace("{frase}", end_verse)

""" Llamar recursivamente a la función con la frase incrustada como frase principal. """
   return recite(start_verse, end_verse)

Please wrap code in a codeblock so it is readable.

If you want help, please include the test output, too, so we can see the code run and test failures.

The true that all tests failed and I don’t understand like resolve it. If you can view a exercise resolved, thanks because I cannot continue with other exercises.

Can you share your code and the test output as text in a codeblock?

This post shows how to format code on the forum.

Hi IsaacG, I’m new here I will try of maked it. give me 5m

def recite(start_verse, end_verse):
    """ start_verse: frase inicial o frase a incrustar.
    end_verse: frase final con incrutsacion.
    """
    if "{frase}" not in start_verse:
        return start_verse
    
    """ Incrustar la frase dentro de la frase principal. """
    start_verse = start_verse.replace("{frase}", end_verse)
    
    """ Llamar recursivamente a la función con la frase incrustada como frase principal. """
    return recite(start_verse, end_verse)
CODE RUN
self.assertEqual(recite(1, 1), ["This is the house that Jack built."])
TEST FAILURE
TypeError: argument of type 'int' is not iterable
CODE RUN
self.assertEqual(
    recite(2, 2), ["This is the malt that lay in the house that Jack built."]
TEST FAILURE
TypeError: argument of type 'int' is not iterable
CODE RUN
self.assertEqual(
    recite(3, 3),
TEST FAILURE
TypeError: argument of type 'int' is not iterable

Do you need all tests? because all tests failed and above there are any.

This one test is plenty :slight_smile:

The error is, TypeError: argument of type 'int' is not iterable. That suggests you’re trying to iterate over a number.

What type of data is start_verse and end_verse? You may want to look at the test code you pasted for clues.

What is this line supposed to be doing? if "{frase}" not in start_verse

start_verse and end_verse are string like phrases because I don’t understand this error type ‘int’?

int is integer, aka a number. start_verse and end_verse numbers, not strings.

Ok, but I don’t understand like make this exercise. Can you share the code this exercise?

The song has a number of verses to it. You’re asked to generate a number of those verses based on the start and end numbers.

Verses 1-4:

This is the house that Jack built.

This is the malt that lay in the house that Jack built.

This is the rat that ate the malt that lay in the house that Jack built.

This is the cat that killed the rat that ate the malt that lay in the house that Jack built.

Verses 3-6:

This is the rat that ate the malt that lay in the house that Jack built.

This is the cat that killed the rat that ate the malt that lay in the house that Jack built.

This is the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.

This is the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.

Given two numbers, generate the expected verses.