Last active
August 29, 2015 14:03
-
-
Save janetriley/54845b6284be7573a349 to your computer and use it in GitHub Desktop.
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
# What if we had a row result from a database? | |
row = ['Mary','10', 'F'] | |
output = 'Name: {name}, age: {age}, gender: {gender}'.format(name=row[0], age=row[1], gender=row[2]) | |
print output | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output = 'Name: {}, age: {}, gender: {}'.format(*row) # This would also work (although less legible)