Skip to content

Instantly share code, notes, and snippets.

@Ismael-VC
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ismael-VC/9143167 to your computer and use it in GitHub Desktop.
Save Ismael-VC/9143167 to your computer and use it in GitHub Desktop.
Checks wheter a string is a valid base 3 number representation.
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