Knock 3 times

Modify the while loop in the function knock_three_times to print the string 'Knock Knock' three times.

Test Cases

test knock three times - Run Test

def test_knock_three_times():
    with CaptureOutput() as output:
        knock_three_times()

    assert len(output) == 3
    assert output == [
        'Knock Knock',
        'Knock Knock',
        'Knock Knock'
    ]

Solution 1

def knock_three_times():
    count = 0
    while count < 3:
        print('Knock Knock')
        count += 1
def knock_three_times(): while YOUR-CONDITION: print("Knock Knock")