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