Frida Kahlo Retrospective Off-Platform Project

<< I am appending a list in the project Frida Kahlo Retrospective Off-Platform Project why is the updated list not printing on the screen and the updated len is printing did i missed something? here is my code

Hi ephony,

To see the updated paintings list just use the print() function on line 14 like so:

print(paintings)

Let me know if this resolves your issue!

1 Like

I’m getting an indentation error at the return line of code, what am i doing wrong here?

Is this the correct method I was able to store the variable audio_tour_number to paintings and utilized the range method and arrived at the solution

On line 20, indent return id by 3 spaces

In my opinion, this does not look correct.

audio_tour_number = paintings, range(1, 7)

You created a tuple

print(audio_tour_number[0])  # paintings
print(audio_tour_number[1])  # range(1,7)

Maybe this is what you’re trying to achieve (?):

for n in range(len(paintings)):
    print(n)

Output

0
1
2
3
4
5

What do the instruction say for these steps?

Since each of these paintings is going to be in the audio tour, they each need a unique identification number. But before we assign them a number, we first need to check how many paintings there are in total.

Find the length of the paintings list.

There were some last minute additions to the show that we need to add to our list. Append the following paintings to our paintings list then re-print to check they were added correctly:

  • 'The Broken Column', 1944
  • 'The Wounded Deer', 1946
  • 'Me and My Doll', 1937

Hey Ephony,

Based on the instructions, there is some error with your code.

Initial Code

paintings = ['The Two Fridas', 'My Dress Hangs Here', 'Tree of Hope', 'Self Portrait With Monkeys']
dates = [1939, 1933, 1946, 1940]

paintings = list(zip(paintings, dates))

Output

[('The Two Fridas', 1939), ('My Dress Hangs Here', 1933), ('Tree of Hope', 1946), ('Self Portrait With Monkeys', 1940)]

Take note of the data structure, it is list[tuple[str, int]]. Now, the instructions state, append the following paintings to our paintings list then re-print to check they were added correctly:

  • 'The Broken Column', 1944
  • 'The Wounded Deer', 1946
  • 'Me and My Doll', 1937

Now, look at your code, lines 7-2, see how you are appending each item one at a time? This is incorrect. You should append the records like so:

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

Quick Note: The append() takes one (1) parameter, so to append multiple values, wrap them up in a set of parenthesis (e.g. tuple). Does that makes sense?

If you need further assistance or have additional questions with this exercise please ask!

I am where you are with that, however I’m still trying to append paintings correctly because the append is showing me two list and it did not add the new painting in the first list. it gave me the list seperate in other words it never append it to the end of the first list.

My code not giving me any error message but nothing is printing to the console
def master_list(num):
items = num
for x in items:
if x == items:
master_list = list(tuple(zip(audio_tour_number, paintings)))
return x

paintings = [‘The Two Fridas’, ‘My Dress Hangs Here’, ‘Tree of Hope’, ‘Self Portrait With Monkeys’]

dates = [1939, 1933, 1946, 1940]

paintings = list(tuple(zip(paintings, dates)))
print(paintings)

paintings =

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

print(paintings)
for items in range(len(paintings)):
audio_tour_number = items
print(items, end= " ")

print(master_list)

these are the instructions

First, create a list called paintings and add the following titles to it:

'The Two Fridas', 'My Dress Hangs Here', 'Tree of Hope', 'Self Portrait With Monkeys'

Next, create a second list called dates and give it the following values:

1939, 1933, 1946, 1940

It doesn’t do much good to have the paintings without their dates, and vice versa. Zip together the two lists so that each painting is paired with its date and resave it to the paintings variable. Make sure to convert the zipped object into a list using the list() function. Print the results to the terminal to check your work.

There were some last minute additions to the show that we need to add to our list. Append the following paintings to our paintings list then re-print to check they were added correctly:

  • 'The Broken Column', 1944
  • 'The Wounded Deer', 1946
  • 'Me and My Doll', 1937

Stuck? Get a hint

Since each of these paintings is going to be in the audio tour, they each need a unique identification number. But before we assign them a number, we first need to check how many paintings there are in total.

Find the length of the paintings list.

Use the range method to generate a list of identification numbers that starts at 1 and is equal in length to our list of items. Save the list to the variable audio_tour_number and check your work by printing the list.

We’re finally ready to create our master list. Zip the audio_tour_number list to the paintings list and save it as master_list.

Stuck? Get a hint

Print the master_list to the terminal.

Hey Ephony,

I reformatted your code. This function will not work. There is a flaw in logic.

def master_list(num):
    items = num
    for x in items:
        if x == items:
            master_list = list(tuple(zip(audio_tour_number, paintings)))
    return x

Reasons

  1. x will never be equal to items. Therefore, master_list will never be set, return x
  2. The variables audio_tour_numbers and paintings are out of scope .

My code not giving me any error message but nothing is printing to the console

That is because you are calling the function incorrectly:

print(master_list)

You need to invoke it with the parenthesis make_list(), and supply a parameter (num). However, as I stated before, this function does not work. This is how I would negotiate this exercise:

# Step 1:
paintings = ['The Two Fridas', 'My Dress Hangs Here', 'Tree of Hope', 'Self Portrait With Monkeys']

# Step 2:
dates = [1939, 1933, 1946, 1940]

# Step 3:
paintings = list(zip(paintings, dates))

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

# Step 5:
print(len(paintings))

# Step 6:
audio_tour_number = []
# (!) NOTE: "idx" represents the identification numbers equal in length to our list of items:
for idx in range(1, len(paintings)):
    audio_tour_number.append(idx)

# # Step 7:
master_list = list(zip(audio_tour_number, paintings))

# Step 8:
for record in master_list:
    print(record)

If you want your function to work try something like this:

def master_list(param):
    output = []
    for idx in range(1, len(param)):
        output.append((idx, param[idx]))
    return output

This provides the functionality of steps 6-7 from my previous solution, and gives the same output.
Let me know if you still have any questions regarding this exercise. I’m more than happy to assist!

2 Likes

Hi there! This code works just perfectly, however, in step 6 I would make a slight change because the for loop is not running through the entire list. Instead, it leaves out the last item on the list. Therefore, I would add one, so that it fully includes everything. :slight_smile:

> for idx in range(1, len(paintings)+1): > audio_tour_number.append(idx)

hope it works!

Can anyone confirm or deny that my logic is correct and that I completed Step 5? which is " There were some last minute additions to the show that we need to add to our list." Append the following paintings to our paintings list then re-print to check they were added correctly" correctly. I appended individualy to each list but i think i may have missed the mark and would appreciate if i could make this more cleaner and efficient

paintings = ['The Two Fridas', 'My Dress Hangs Here', 'Tree of Hope', 'Self Portrait With Monkeys'] dates = [1939, 1933, 1946, 1940] paintings = list(zip(paintings,dates)) print(paintings) paintings.append('The Broken Column') dates.append(1944) paintings.append('The Wounded Deer') dates.append(1946) paintings.append('Me and My Doll') dates.append(1937) print(paintings) audio_tour_number = [i for i in range(1,len(paintings)+1)] print(audio_tour_number) master_list = list(zip(audio_tour_number, paintings)) for record in master_list: print(record)

#get-help #project #community

Hello! I don’t believe that you appended correctly to the ‘paintings’ list. Python will read your code from top to bottom. In this case, you have:

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

…what you’re doing here is appending the names of the additional paintings to the ‘paintings’ list. And then you’re appending the new dates to the ‘dates’ list. Therefore, when you 'print(paintings'), it will only print [('The Two Fridas', 1939), ('My Dress Hangs Here', 1933), ('Tree of Hope', 1946), ('Self Portrait With Monkeys', 1940), 'The Broken Column', 'The Wounded Deer', 'Me and My Doll'] without the year for the last 3 items in the last.

TLDR:
What you could do is create a new list with the last minute additions:

lst_min_paintings = [('The Broken Column',1944),('The Wounded Deer',1946),('Me and My Doll',1937)]

And then use a loop to add each item to the paintings list.

for lsmin_painting in lst_min_paintings:
    paintings.append(lsmin_painting )
print(paintings)

The output should appear:

[('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)]

First time assisting here but please let me know if there is still an issue/confusion!
Link to jypter: frida_project.ipynb

2 Likes

Hello tamimislam

You should append both the paintings and dates in a single argument.
Here is the code I recommend to append both paintings and dates in a single argument.
Take note that I have appended it 3 times.

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

The output should appear 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)]

Hope this helps

Cheers :+1:

1 Like

Hello amducruet04

Step 6 instruction is:
Use the range method to generate a list of identification numbers that starts at 1 and is equal in length to our list of items. Save the list to the variable audio_tour_number and check your work by printing the list.

Here is the code I would like to suggest:

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

There is no need to use for loop.

Thank you

1 Like

Hello World

Here is my solution for the Frida Kahlo Retrospective Off-Platform Project

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

dates = [1939, 1933, 1946, 1940]

paintings = list(zip(paintings, dates))
print(paintings)

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

print(len(paintings))

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

master_list = list(zip(audio_tour_number, paintings))
print(master_list)

Appreciate any feedback!

1 Like

My “only” 3-hour problem is that I didn’t put the list before the range.
audio_tour_number = range(1, len(paintings) + 1))
Thank you for eye-opening, sir.