Created
February 22, 2017 14:06
-
-
Save citrusui/c05bb282927b40df82ab6970da5be98c to your computer and use it in GitHub Desktop.
Input for a user's name, and print it in a variety of ways.
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
"""Import system module.""" | |
import sys | |
import time | |
"""Print the user's name in a variety of ways.""" | |
def nametricks(): | |
"""Input for first and last name.""" | |
name = None | |
name = input("\nPlease enter your name: ").title().split() | |
if len(name) < 2: | |
print("Missing a last name!") | |
nametricks() | |
elif len(name) > 2: | |
print("Sorry, no middle names.") | |
nametricks() | |
else: | |
print("\nHi %s %s!" % (name[0], name[1])) | |
print("\n%s %s, hi!" % (name[1], name[0])) | |
print("") | |
newname = ' '.join(name) | |
for char in newname: | |
sys.stdout.write(char) | |
sys.stdout.flush() | |
time.sleep(2) | |
nametricks() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment