Frida kahlo Retrospective code review

Hello Everyone < I am 20 percent through the data Scientist carrear path of data scientist -NLP
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 any of your code if you want so kindly go through my code and if there is any suggestions you can make kindly let me know

paintings = [“The Two Fridays”, “My Dress Hangs Here”, “Tree Of Hope”, “Self Portrait With Monkeys”]
dates = [1939, 1933, 1946, 1940]
#code for combining the two given list using zip function
paintings = list(zip(paintings, dates))

#last minutes additions which needs to be appended in paintings
additional_paintings = [[“The Broken Column”, 1944], [“The Wounded Deer”, 1946], [“Me and My Doll”, 1937]]

#appending the list to painting
paintings = paintings + additional_paintings

#paintings length
painting_length = len(paintings)

#identification number assigning task
audio_tour_number = list(range(1,(painting_length + 1)))

#zipping this list to previos list to complete the master list
master_list = list(zip(paintings, audio_tour_number))

1 Like

What does your master list look like? Does it have mixed data types?

ahh its a kind off a mixed data type like it is a tuple containing another tuple (or a list) and an integer. so like it is a bit diffrent than what was expected but like it was saying to zip it twice so i guess it is alright right?


Please post a link to this project’s landing page so we can read the narrative and instructions, and try out a solution.

this here is the link but i dont know if it will open or not so i just in case i will be sending below the snips of the instructions as well okay

please review my code and let me know if you have any suggestion
thank you


Line 8 should be a list of tuples. That way when you extend the list, all the data points are the same type. The way you are extending the list is fine, but you may wish to write it as three appends.

Here is the final result that I got:

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

There is an alternate way to do the ‘zip range with the paintings’ step that doesn’t need a length or a range:

master_list = [*enumerate(paintings)]

I used that for my last step to produce the output above.


didn’t understood ahhh i think we both are getting a tuple of tuple and a int its just that you are getting a tuple of int and tuple and i am getting a tuple of tuple and int so if i just change the order of the last zip statemen we will get the same output and in line 8 what you are saying is true that we can append the data but then i think appending the data using three different line and what i have done is same no?

basically no offense but i was not able to undestand your point correctly can you please break it down to me

Correct. TBH, I like the extend method as opposed to appending since it can all be done in one statement. So long as you are aware of the difference and similarity to append.

As for the order, it just makes sense to me to have the number first, which is how enumerate() returns it.

Which point to you mean? the enumerate() function? the star operator (‘splat’)?

1 Like

yes i was not able to understand that enumerate point as i have not yet used it or it is not introduced idk can you please just explain about it otherwise rest of your explanation was perfect
thank you

I seem to remember learning about the enumerate() function in the unit on iterators, which it returns. It does what the name suggests: enumerate a list. Like zip() it is consumed when accessed, which is why both need to be made into a list if we wish to do more than just iterate over them. The function, like zip is a list method. Not sure it will work with tuples or sets. Would have to experiment.

Consider the following example:

a = [*'abcdefghijklmnopqrstuvwxyz']
for i, x in enumerate(a):
    print (i, x)
0 a
1 b
2 c
3 d
4 e
5 f
6 g
7 h
8 i
9 j
10 k
11 l
12 m
13 n
14 o
15 p
16 q
17 r
18 s
19 t
20 u
21 v
22 w
23 x
24 y
25 z
1 Like

Got it thank you for your explanation it is a new lesson for me i will try it in further exercise to fully master the topic and again
Thank you very much your explanation was very good

1 Like

I’m guessing you must have caught that my output is not what is expected. We used the range to bump up the numbers by 1, and not start on zero. Was so fixated it didn’t even occur to me, until now. D’oh!

a = [*'abcdefghijklmnopqrstuvwxyz']
for i, x in enumerate(a):
    print (i + 1, x)
1 Like

yeah little bit but i got it now thanks

1 Like