Last active
December 23, 2015 03:09
-
-
Save Lysander/6571676 to your computer and use it in GitHub Desktop.
Lösung zur verlinkten Aufgabe aus: http://forum.ubuntuusers.de/post/5937547/
This file contains hidden or 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
| SuperDepp =1 True | |
| superdepp= 3 True | |
| sUperdepp = 5 True | |
| superdepp = 7 True | |
| superdepp =9 True | |
| superdepp= 3 True | |
| Superdepp=7 True | |
| SUPERDEPP=7 True | |
| suppendepp=11 False | |
| hupersep= b False | |
| superdepp=a False | |
| sUperdep=c False | |
| superdepp==7 False | |
| superdepp-9 False | |
| superdepp 3 False | |
| superdepp 7 False | |
| pupersepp=7 False | |
| SUPERdepp= 3 True | |
| superDEPP= 5 True | |
| SUPERDEPP= 7 True | |
| SUPERDEPP= 9 True | |
| SUPERDEPP= 7 True | |
| SUPERDEPP= 9 True | |
| SuPeRdEpP=9 True |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| data = """ | |
| SuperDepp =1 | |
| superdepp= 3 | |
| sUperdepp = 5 | |
| superdepp = 7 | |
| superdepp =9 | |
| superdepp= 3 | |
| Superdepp=7 | |
| SUPERDEPP=7 | |
| suppendepp=11 | |
| hupersep= b | |
| superdepp=a | |
| sUperdep=c | |
| superdepp==7 | |
| superdepp-9 | |
| superdepp 3 | |
| superdepp 7 | |
| pupersepp=7 | |
| SUPERdepp= 3 | |
| superDEPP= 5 | |
| SUPERDEPP= 7 | |
| SUPERDEPP= 9 | |
| SUPERDEPP= 7 | |
| SUPERDEPP= 9 | |
| SuPeRdEpP=9 | |
| """ | |
| def is_valid(expression): | |
| try: | |
| name, value = expression.split("=") | |
| if name.strip().lower() == "superdepp" and int(value.strip()) > 0 \ | |
| and int(value.strip()) < 11: | |
| return True | |
| else: | |
| return False | |
| except ValueError: | |
| return False | |
| if __name__ == "__main__": | |
| expressions = data.strip().split("\n") | |
| for expression in expressions: | |
| print(expression, is_valid(expression)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment