Last active
February 21, 2016 13:31
-
-
Save csiknor/144595f87b4318d6fa53 to your computer and use it in GitHub Desktop.
This python script reads user input and piggifies it after validation. Created for a Python assignment on Codecademy.
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
| def read(): | |
| word = raw_input("Gimme your word:") | |
| if len(word) == 0: | |
| print "You must say something" | |
| return read() | |
| elif not word.isalpha(): | |
| print "It's not a word, honey! (No spaces, numbers allowed...)" | |
| return read() | |
| else: | |
| return word | |
| def piggify(s): | |
| if len(s) == 1: | |
| return s + "ay" | |
| else: | |
| return s[1:] + s[0] + "ay" | |
| print piggify(read().lower()) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is what they suggest as a solution...