#๐Ÿ”’ Difficulty understanding how to go about school assignment

50 messages ยท Page 1 of 1 (latest)

upper flintBOT
#

@turbid walrus

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

upbeat flume
#

Do you need help still

left steeple
#

!paste

upper flintBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

turbid walrus
#

Im trying to create a script where I get an input about the number of books per genre, and the title of each book

but I cant figure out how to print each specific genre with its own titles

wise sequoia
#

It would be cleaner to do something like make the keys of the dictionary the genre names.

turbid walrus
#

i thought about creating difference genres as keys, and then moving the titles to each corresponding list, but then what would be the point of the genreList?

wise sequoia
#

It indeed doesn't make much sense since the dictionary is effectively useless then.

#

What are the exact instructions?

turbid walrus
#

i can send them, hold on

#

sigh okay nevermind

#

bad link

wise sequoia
#

A screenshot would work too assuming the instructions aren't over multiple pages.

turbid walrus
#

thank you ill do that

#

these are the instructions and an example of what the output is meant to look like

wise sequoia
#

These instructions don't make much sense to me, I'll be honest.

turbid walrus
#

I was worried I was missing something

wise sequoia
#

It doesn't say what the purpose of inventory is for example, despite mandating its use.

turbid walrus
#

yeah, maybe I do need to go ahead and create separate keys for each genre?

wise sequoia
#

The "proper" way to tackle a problem like this would be to do something like make the dictionary keys the genre titles, and the value a new list.

wise sequoia
#

Well, that's how I'd do it.

#

I don't know what they want.

turbid walrus
#

okay thank you, I just wanted to make sure it wasnt just me that was confused

wise sequoia
#

"genreList will be reused for each genre" and the lack of explanation on what inventory is for are the confusing parts.

#

genreList being "reused" is a bit confusing.

#

I'm not sure what they mean by "reuse", since that kind of suggests the list is wiped between genres or something.

turbid walrus
#

i did make it so it got wiped before the next input, however that just made it so only the last stored list was printed

#

I also thought about adding it to genreList, and then adding it to each respective genre, but that seemed like an unnecessary extra step.

wise sequoia
#

I feel like there's some context missing. The "Start by modifying" instruction suggests there was previous context.

turbid walrus
#

well there was a previous assignment I had, where I was supposed to ask the user for how many books were in each genre, and then printing the genres with books.

#

so for example if i put 1 for narrative, 4 for mystery, and 0 for fiction, it would only print narrative and mystery

wise sequoia
#

The other way this could be done is by making the genreList hold dictionaries that hold both pieces of infiormation:

genreList = [{title: 'Blah', genre: 'Some Genre'}, {title: 'Blah 2', genre: 'Some Other Genre'}]

But inventory would do a better job than that for most cases,

turbid walrus
#

So I have a question, does python support a dictionary in a list nested in another dictionary?

wise sequoia
#

You can nest structures infinitely (assuming infinite memory).

#

You can't have a list as a key to a dictionary, but they can be nested forever as values.

turbid walrus
#

so would I be able to put a dictionary in the genreList? and that would hold each genre? The name makes me think thats what it wants but I still dont understand what they want Inventory for

#

It confused me that they have me title it genreList and have it hold the titles

wise sequoia
#

You might want to ask for clarification. There's only so much we can do with poor instructions.

turbid walrus
#

Okay, if I cant figure it out by doing the dict list dict nesting structure then Ill ask for clarification

#

thank you

wise sequoia
#

You're welcome.

upper flintBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.