Last active
August 29, 2015 13:56
-
-
Save Ismael-VC/9143167 to your computer and use it in GitHub Desktop.
Checks wheter a string is a valid base 3 number representation.
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
In [1]: valid_base_3_digits = ['0', '1', '2'] | |
In [2]: for digit in '012': | |
...: if digit not in valid_base_3_digits: | |
...: print("That won't work!") | |
...: else: | |
...: print("Seems right!") | |
...: | |
Seems right! | |
Seems right! | |
Seems right! | |
In [3]: for digit in '0123': | |
...: if digit not in valid_base_3_digits: | |
...: print("That won't work!") | |
...: else: | |
...: print("Seems right!") | |
...: | |
Seems right! | |
Seems right! | |
Seems right! | |
That won't work! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment