Frida Kahlo Retrospective Code Review

Hello Everyone,

I am 33% threw the BI Data Intelligence career path. I have completed the Frida Kahlo off platform project. I am hoping to find a partner to review my code, and I am happy to review yours.

I would appreciate feedback on the following code:
#Creating two list first paintings then the dates they were made
paintings = [‘The Two Fridas’, ‘My Dress Hangs Here’, ‘Tree of Hope’, ‘Self Portrait With Monkeys’]
dates = [1939, 1933, 1946, 1940]

zip together both the paintings and their dates

paintings_and_dates = list(zip(paintings, dates))
#print new zipped 2d list

print(paintings_and_dates)

append zipped(paintings_and_dates) to contain last minute additions

new_painting1 = [“The Broken Column”, 1944]
new_painting2 = [“The Wounded Deer”, 1946]
new_painting3 = [“Me and My Doll”, 1937]
paintings_and_dates.append(new_painting1)
paintings_and_dates.append(new_painting2)
paintings_and_dates.append(new_painting3)

print(paintings_and_dates)

find out the length of zipped foler

len(paintings_and_dates)

create identification numbers using range method

audio_tour_number = list(range(1,8))
print(audio_tour_number)

#combine paintings and tour number to create master list
master_list = list(zip(audio_tour_number, paintings_and_dates))
print(master_list)
len(master_list)

happy coding!

I think some code is missing (output of the various print())

To add the new paintings, it’s easier to do this and add each item as they’ve requested (rather than create separate variables for each):

paintings.append(('The Broken Column', 1944))
paintings.append(('The Wounded Deer', 1946))
paintings.append(('Me and My Doll', 1937))

print(paintings)

>>>[('The Two Fridas', 1939), ('My Dress Hangs Here', 1933), ('Tree of Hope', 1946), ('Self Portrait With Monkeys', 1940), ('The Broken Column', 1944), ('The Wounded Deer', 1946), ('Me and My Doll', 1937)]

Python Docs, list methods:

1 Like

thank you very much! I see how that can be much simpler!

1 Like

Hey, when you zipped to the master list, did you get double (())?

[(1,(‘The Two Fridas’, 1939)), (2,(‘My Dress Hangs Here’, 1933)), (3(‘Tree of Hope’, 1946)), etc.]

What code did you write to get that?
Please post all of your formatted code. Use the “</>” button to format.

audio_tour_number=list(range(1, len(paintings)+1))
print(audio_tour_number)
master_list=list(zip(audio_tour_number, paintings))
print(master_list)

Close.
Up until that point, after appending three paintings separately, you had a list of tuples, like this:

[('The Two Fridas', 1939), ('My Dress Hangs Here', 1933), ('Tree of Hope', 1946), ('Self Portrait With Monkeys', 1940), ('The Broken Column', 1944), ('The Wounded Deer', 1946), ('Me and My Doll', 1937)]

So, from the previous step (5?), we know the length of the list is 7.
print(len(paintings))
>>7

So, the next step (6?)

#range() takes 3 inputs-start, stop, step(optional).

audio_tour_number = list(range(1, 8))
print(audio_tour_number)
>>[1, 2, 3, 4, 5, 6, 7]

And then 7, one way to do that is how you have it

master_list = list(zip(audio_tour_number, paintings))
print(master_list)
#which gives you this output
>>>[(1, ('The Two Fridas', 1939)), (2, ('My Dress Hangs Here', 1933)), (3, ('Tree of Hope', 1946)), (4, ('Self Portrait With Monkeys', 1940)), (5, ('The Broken Column', 1944)), (6, ('The Wounded Deer', 1946)), (7, ('Me and My Doll', 1937))]

And another way is with a list comprehension:

master_list = [list(x) for x in zip(audio_tour_number, paintings)]
print(master_list)

>>[[1, ('The Two Fridas', 1939)], [2, ('My Dress Hangs Here', 1933)], [3, ('Tree of Hope', 1946)], [4, ('Self Portrait With Monkeys', 1940)], [5, ('The Broken Column', 1944)], [6, ('The Wounded Deer', 1946)], [7, ('Me and My Doll', 1937)]]

I think either way for creating the master_list passes, right?

OK. thanks for the help.
It seems either way you end up with the number on the outside of the original info tuple:
#,(‘name’, date), which I was trying to resolve, with the goal of having the number inside the original tuple such as:
(#, ‘name’, date), but i guess since it is a tuple (non-mutable), this will be the result no matter what?

Hi Mac,

I also thought to set the identification number inside the tuple, here my solution, I blur the solution in case some people prefer to look into it by themselves.

[spoiler]

paintings = ['The Two Fridas', 'My Dress Hang Here', 'Tree of Hope', 'Self Portrait With Monkeys']

dates = [1939, 1933, 1946, 1940]

paintings_and_dates = list(zip(paintings, dates))

paintings_and_dates.append(('The Broken Column', 1944))
paintings_and_dates.append(('The Wounded Deer', 1946))
paintings_and_dates.append(('Me and My Doll', 1937))

length = len(paintings_and_dates)

audio_tour_number = list(range(0, length))

master_list = audio_tour_number + paintings_and_dates

master_list = []

## I was not sure if I needed the identification number inside the tuple or not, so I decided to put it inside the tuple as it required more challenge to the task.

for n in audio_tour_number:
  new_list = list(paintings_and_dates[n])
  new_list.append(n + 1)
  new_list.reverse()
  master_list.append(new_list)

print(master_list)
[/spoiler]

Result:

[[1, 1939, ‘The Two Fridas’], [2, 1933, ‘My Dress Hang Here’], [3, 1946, ‘Tree of Hope’], [4, 1940, ‘Self Portrait With Monkeys’], [5, 1944, ‘The Broken Column’], [6, 1946, ‘The Wounded Deer’], [7, 1937, ‘Me and My Doll’]]