Exercise 3:
Write a Python program that prompts for input and displays a cat "saying" what was provided by the user. Place the input provided by the user inside a speech bubble. Make the speech bubble expand or contract to fit around the input provided by the user.
Sample Output:
Solution:
#!/usr/bin/env python3
text = input('What would you like the cat to say? ')
text_length = len(text)
print(' {}'.format('_' * text_length))
print(' < {} >'.format(text))
print(' {}'.format('-' * text_length))
print(' /')
print(' /\_/\ /')
print('( o.o )')
print(' > ^ <')
No comments:
Post a Comment