Last active
April 20, 2017 10:02
-
-
Save Makistos/099f38667f96a154fa29c77bffbda98e to your computer and use it in GitHub Desktop.
Check if a string only has valid words. #python
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
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