Created
February 25, 2011 19:59
-
-
Save maraca/844398 to your computer and use it in GitHub Desktop.
Display items nicely
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
#!/usr/bin/python2.6 | |
# Copyright (c) 2011, Formspring.me. | |
"""Enter brief description here. | |
Enter more details here about this file. | |
""" | |
__author__ = '[email protected]' | |
if __name__ == '__main__': | |
grocery = """chocolate: 1 | |
banana: 10 | |
sirup: 20 | |
blah: 120""" | |
width = len(max(grocery.split('\n'))) | |
for item in grocery.split('\n')[:]: | |
word = item.split(': ')[0] | |
quantity = item.split(': ')[1] | |
print '%s%s' % (word.ljust(width), quantity) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment