Skip to content

Instantly share code, notes, and snippets.

@janetriley
Last active August 29, 2015 14:03
Show Gist options
  • Save janetriley/54845b6284be7573a349 to your computer and use it in GitHub Desktop.
Save janetriley/54845b6284be7573a349 to your computer and use it in GitHub Desktop.
# 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
@sebastiandres
Copy link

output = 'Name: {}, age: {}, gender: {}'.format(*row) # This would also work (although less legible)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment