Creating a List to count objects

Hi everyone,
so I’m creating my 1st skill path project and wanted to post. I didn’t get it all right …still working on it.
Finding myself over stimulated so code community have at it.
HELP! :slight_smile:

#>>>>create an app that counts how many pairs of shoes are in your closet.
#numbers from 1-13

#seperate them by brand.
#List name brand and how many
#create a list.

pairs_of_shoes = (‘stacey_adams’, ‘timbalands’, ‘jordans’, ‘nike’, ‘gucci’)
shoes_in_closet = stacey_adams_shoes[4]
shoes_in_closet = timbalands_shoes[2]
shoes_in_closet = jordans_shoes[4]
shoes_in_closet = nike_shoes[3]
shoes_in_closet = gucci_shoes[0]
for pairs in shoes:
print(shoes)

pairs =
for x in range(1, 13):
pairs.append(x2)
pairs = [x
2 for x in range(1,13)]

#<<<<add together pairs of shoes in list.

This would appear to be only a corresponding list. There are five brands, so there should be five values in this list (or tuple).

shoes_in_closet = (4, 2, 4, 3, 0)

The only issue with using a tuple is it cannot be mutated like a list. However, in their present state, the above two tuples can be merged into a single list:

pairing = []
for i in range(len(pairs_of_shoes)):
    pairing.append((pairs_of_shoes[i], shoes_in_closet[i]))

The finished product should look something like this…

[
  ('Stacey Adams', 4),
  ('Timbalands', 2),
  ('Jordans', 4),
  ('Nike', 3),
  ('Gucci', 0)
]

Hi mtf, thanks for your feedback. so i basically needed to finish the formula as just a list…right?
i think i see what you did.

also, i tried another formula out…look at this one for me mtf. i feel like i’m mixing the wrong functions…

#seperate them by brand.
#List name brand and how many
#create a list.

def pairs_of_shoes (staceyadams, timbalands, jordans, nike, gucci):

staceyadams_shoes = staceyadams
timbalands_shoes = timbalands
jordans_shoes = jordans
nike_shoes = nike
gucci_shoes = gucci

def shoes_sum(num_iterations):
staceyadams = 4
timbalands = 2
jordans = 4
nike = 3
gucci = 0

for sum in pairs_of_shoes:
print(shoes_sum)

pairs = [4, + 2, + 4, + 3, + 0]
pairs.append(‘staceyadams’)
pairs.append(‘timbalands’)
pairs.append(‘jordans’)
pairs.append(‘nike’)
pairs.append(‘gucci’)

squares =
for x in range(1, 13):
squares.append(x2)
squares = [x
2 for x in range(1,13)]

i’m getting an error on line 26 (for sum in pairs…)

Please post a link to the exercise so we can review the narrative and read the instructions.

is there a way to go back through IT course after completion? it was apart of my Course Project.

Yes, there are two ways:

  • from the dashboard, reset the entire unit
  • from an individual lesson, reset the exercise

Nothing is preventing us from going back through tracks for review, redo and for practice. Once all the checkmarks are in place, we can still use the lesson space to practice or attempt different methods. The lesson checker is disabled at that point, so just don’t click Next. We can click Run as much as we want.

1 Like