Skip to content

Instantly share code, notes, and snippets.

@gphilipp
Last active January 15, 2016 10:43
Show Gist options
  • Select an option

  • Save gphilipp/87d7278ed72fde3adc1a to your computer and use it in GitHub Desktop.

Select an option

Save gphilipp/87d7278ed72fde3adc1a to your computer and use it in GitHub Desktop.
# i'd like to have this printed out, using nested zip data structures:
# john eats roasted pizza
# mary eats raw vegetables
# john eats tender chicken
# But there's an error at line 'for f, c in fc:' saying: ValueError: too many values to unpack
people = ["john", "mary", "doug"]
food = ["pizza", "vegetables", "chicken"]
cooked = ["roasted", "raw", "tender"]
food_cooked = zip(food, cooked)
people_food_cooked = zip(people, food_cooked)
for p, fc in people_food_cooked:
for f, c in fc:
print(p + "eats " + c +" " + f)
# Note : the end goal is not to print, I know I can do
for p,f,c in zip(people, food, cooked):
print (p + " eats " + c + " " + f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment