Issues with Class


#1

Hello! I am having issues with a class that I created! I am receiving the below traceback error. I am not sure what I am doing wrong. I also included the JSON that I am trying to parse through. Any help would be great!

 File "project.py", line 231, in <module>
    new_photo = Photo(result_get_photo_data)
  File "project.py", line 228, in __init__
    for diction in photo_diction["photo"]["tags"]["tag"]:
TypeError: list indices must be integers, not st

class Photo(object): 
	def __init__(self,photo_diction):
		self.tags = []
		for diction in photo_diction["photo"]["tags"]["tag"]:
			return self.tags.append(diction)

new_photo = Photo(result_get_photo_data)
print new_photo.tags

JSON:

{"photo": {"people": {"haspeople": 0}, "dateuploaded": "1492774605", "originalformat": "jpg", "owner": {"username": "brandready", "realname": "Brand Ready", "nsid": "135810789@N04", "iconserver": "632", "location": "", "path_alias": "brandready", "iconfarm": 1}, "publiceditability": {"canaddmeta": 0, "cancomment": 1}, "id": "34175693755", "title": {"_content": "How the Modern Viewer (& Cupcakes) Transformed Saturday Night Live http://bit.ly/2obm7by"}, "media": "photo", "tags": {"tag": [{"machine_tag": false, "_content": "inbound", "author": "135810789@N04", "raw": "Inbound", "authorname": "brandready", "id": "135778650-34175693755-671110"}, {"machine_tag": false, "_content": "marketing", "author": "135810789@N04", "raw": "Marketing", "authorname": "brandready", "id": "135778650-34175693755-2141"}, {"machine_tag": false, "_content": "wordpress", "author": "135810789@N04", "raw": "WordPress", "authorname": "brandready", "id": "135778650-34175693755-5241"}]}, "comments": {"_content": "0"}, "secret": "0271edaa81", "usage": {"canblog": 0, "canshare": 1, "candownload": 1, "canprint": 0}, "description": {"_content": "<a href=\"http://bit.ly/2p2CTZP\" rel=\"nofollow\">bit.ly/2p2CTZP</a>"}, "isfavorite": 0, "views": "0", "farm": 4, "visibility": {"isfriend": 0, "isfamily": 0, "ispublic": 1}, "rotation": 0, "dates": {"taken": "2017-04-21 04:36:45", "takenunknown": "1", "takengranularity": 0, "lastupdate": "1492774626", "posted": "1492774605"}, "originalsecret": "97536e3b51", "license": "0", "notes": {"note": []}, "server": "3936", "safety_level": "0", "urls": {"url": [{"type": "photopage", "_content": "https://www.flickr.com/photos/brandready/34175693755/"}]}, "editability": {"canaddmeta": 0, "cancomment": 0}}, "stat": "ok"}