Created
November 14, 2018 04:08
-
-
Save RafaelBroseghini/12a979b4ccaf31a8d00059e5b0b4930f to your computer and use it in GitHub Desktop.
Guess and Check Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This pattern guesses and checks if there are any even numbers in a given array | |
and returns True or False. | |
""" | |
def guess_and_check(array: list) -> bool: | |
if len(array) == 0: | |
return False | |
found = False | |
i = 0 | |
while not found and i < len(array): | |
if array[i] % 2 == 0: | |
found = True | |
i += 1 | |
return found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment