27 июля 2022
Vijay vijjiHlo mentor did you got?
Have you tried solving it on your own?
If you have, send code let's try and get through it.
If not, then let's talk about how you can achieve your goal
Benjamin FarunaHave you tried solving it on your own?
If you have, send code let's try and get through it.
If not, then let's talk about how you can achieve your goal
I didn't get solution so that I am taking ur help...if u know tell me..
Vijay vijjiI didn't get solution so that I am taking ur help...if u know tell me..
I can't give you solution to a problem you haven't solved in any way. At least show code of what you've tried.
Okay... Since you're summing up the amount per month, I'd advice you use a nested dictionary to achieve that, since you need minimal code access different months under a specific year.
The dictionary could be something like
year: {
month: amount
}
When a month doesn't exist, you simply add it to the year dictionary, and when it exists, you add the amount to the already existing value
Benjamin FarunaOkay... Since you're summing up the amount per month, I'd advice you use a nested dictionary to achieve that, since you need minimal code access different months under a specific year.
The dictionary could be something like
year: {
month: amount
}
When a month doesn't exist, you simply add it
I hope this makes enough sense
Vijay vijjiFor nested dictionary we have to import CSV module
No need to import CSV
From the output you're getting from splitting each line of text, you can select the indexes meant for each row and put them in their appropriate locations.
{
"2022":
{
"1": amount,
"2": amount,
},
"2021":
{
"3": amount
}
That's what it should look like.
Vijay vijjiFor nested dictionary we have to import CSV module
Sorry I'm replying late, I just got back online