Toggle QuestionsΒΆ

Put the blocks in order to define the function has22 to return True if there are at least two items in the list nums that are adjacent and both equal to 2, otherwise return False. For example, return True for has22([1, 2, 2]) since there are two adjacent items equal to 2 (at index 1 and 2) and False for has22([2, 1, 2]) since the 2’s are not adjacent.

Before you keep reading...

Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.

Finish the function has22 below to return True if there are at least two items in the list nums that are adjacent and both equal to 2, otherwise return False. For example, return True for has22([1, 2, 2]) since there are two adjacent items equal to 2 (at index 1 and 2) and False for has22([2, 1, 2]) since the 2’s are not adjacent.

You have attempted 1 of 5 activities on this page