Skip to content

Instantly share code, notes, and snippets.

@Makistos
Last active April 20, 2017 10:02
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 Makistos/099f38667f96a154fa29c77bffbda98e to your computer and use it in GitHub Desktop.
Save Makistos/099f38667f96a154fa29c77bffbda98e to your computer and use it in GitHub Desktop.
Check if a string only has valid words. #python
import sys
valid_words = ('opsub', 'opequal', 'opadd', 'opmult', 'oprdiv', 'opidiv')
def is_valid(str):
return all(word in valid_words for word in str.split())
not_validated = sys.argv[1]
if is_valid(not_validated):
print "OK"
else:
print "Fail"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment