0

name of list's element

I need to use name of list's element in my code. pets = [panky, sunny, frosty] I need to use 'panky' in print(). Not key or values.

9th Sep 2017, 7:11 AM
Marina Homenko
Marina Homenko - avatar
9 ответов
0
because it's not string it's dictionary
9th Sep 2017, 10:20 AM
Marina Homenko
Marina Homenko - avatar
0
panky = { 'pet': 'dog', 'breed': 'poodle', 'owner': 'john' } ... it's a nested list and I need to get after (cycle for) print(): Panky is a John's poodle.
9th Sep 2017, 10:38 AM
Marina Homenko
Marina Homenko - avatar
0
it' the assignment in my book. can not this be done?
9th Sep 2017, 10:56 AM
Marina Homenko
Marina Homenko - avatar
0
panky = { 'pet': 'dog', 'breed': 'poodle', 'owner': 'john' } sunny = { 'pet': 'cat', 'breed': 'sphynx', 'owner': 'stive' } sunny = { 'pet': 'parrot', 'breed': 'budgie', 'owner': 'lusy' } pets = [panky, sunny, frosty] for pet in pats: print(?????? + 'it's '+ pet['owner'].title() + '\'s ' + pet['pet'] + '.')
9th Sep 2017, 11:23 AM
Marina Homenko
Marina Homenko - avatar
0
you don't understand my question. I need to use NAME pets[0] pets[1] pets[2]
9th Sep 2017, 12:13 PM
Marina Homenko
Marina Homenko - avatar