Basta Fazoolin'

error messages tell you where things crash, they don’t tell you where the mistake is.
at that though, you can inspect what is happening, you can consider what it should have been instead, maybe the input is wrong, maybe you’re doing the wrong thing with the input

if you know the input to whatever you’re doing is wrong then you’d
look at where that was defined.

why would you change it if it’s correct? I think you’re forgetting an important step here, to consider what it should be. you would only change something that you have found to be different from what you meant.

if you have a list that you pass around between functions and they add and remove things to that list, that would be communication between the functions

instead of a list you have an object where you are reading and writing to its attributes. same thing as if it was a list

so if you want the list to end in 0, and it ends in 5, then you’d check whatever function was supposed to ensure 0 was the last value. the problem is saying a lot about where the mistake is

same with your loop. if the input to your loop is wrong, then, where did you get it from, who put that there, fix it.

perhaps the most important part here is that you control all of it. YOU. if you don’t know what something in your program does, then you have to go fix that, because you have to know what everything does in your code, if you’re not in control of it then who is? certainly not the computer, the computer just does what you say.
if you don’t know what something does, that is a bug.

You had some self.menus
you expected it to be a list of menu items.
it isn’t.
who set it?
__init__ did, presumably. you know where, you wrote the code.
so you’d start over in __init__, considering the situation there, comparing to what you meant should happen.

only you can say what the fix should be. python can’t tell you, I can’t tell you. you get it by considering what you meant.

I made no suggestions on what to change. what you had in your code was contradictory, all I said was you had to go with one or the other, and that you would have to consider which you meant to be able to tell which

and if you don’t know what you mean should happen well then you better figure that out because otherwise what are you writing?

because I am learning and don’t know better. So when there is an error that I’m working with for 4 hours and the there is a part of code throwing the error that I know is correct I’m going to try something else to try and get it to work.

In the end I a:b my code against the answer’s code and it was 1 to 1 with the exception of a few variables names.
I’m well aware that debugging and figuring out the errors requires going through and finding what’s wrong with the code. Your over simplification is appreciated but was already taken into consideration for the first few hours that I spent trying to figure it out before I came to ask for help here.

nope I was not - i was expecting it to be literally a list of menu names - as I had created it to be. The returning of the list is something i couldn’t even get to because I couldn’t get past the first part of the method.
but! if i was asked to loop through the menu items I now know i could by using menu.items inside the loop of self.menus and I am pretty excited to have just figured that out.

Exactly this. This is why I came to ask a question on a help forum - I was having trouble knowing what I was writing with self./menu. etc in that for loop and why it was not working as expected. That is why I came for help… not to learn that I need to know that I have to figure it out.

much appreciated!

alright, a list of strings.
but if it’s a list of strings, then they would not have begin and end times. right?

if you expect it to be a list of strings, then you wouldn’t do this:

because that’s not something that makes sense for strings.

so then you’d say, alright, the input is right here, but this isn’t what I meant to do. what did I mean to do? do that instead.
or maybe you meant to look at some other input. or maybe you didn’t provide it anywhere, and would have to make it available.
whichever part of this doesn’t match your expectation is what you would change, and, if it doesn’t match your expectation then it’s wrong, at that point you know you’re not changing something correct, you’ve determined it’s wrong and needs changing

the for loop iterates through the menu name’s
the if statement checks whether the time is within the start and end times within the menu’s data.

yes there was something wrong and it needed changing.
I figured it out by moving the position of my code around - changing the actual text of the code(what pointed where etc…) was not the right thing to do. which was confusing.
Moving the position of the code without touching the actual content of the code made it match expectations.

Thank you for your input this thread can be closed.

is a name a string?
and does a string have a start and end time?

more likely, you meant to have menus in that list, not strings. presumably a menu would know its name and its start time and its end time

when you say moving things around fixed it, that makes me wonder whether you simply stopped executing the problem or whether you actually fixed it. if you don’t execute crashing code then there’ll be no crash. but you also wouldn’t get a result, it would be the same as not having any code

I’m confused why you are continuing with this thread at this point?

I did not get the help i needed from this thread and I was able to find the issue and resolve it based on the video in the exercise that is made by codecademy to walk you through the exercise. The exercise asks you to test your code… i test it… it yields the correct results. Second guessing myself I have looked up other people’s code on this exercise and also see matching code that works.

As i said before, I’m happy to share my code if you are skeptical(?), though I thought it was against the rules to post completed exercises in the help forums.

anyway, thank you for trying to help!

Because you were saying you didn’t see how to figure out what to change based on the situation you had.

And also because you’re saying it pretty much fixed itself without knowing why. Code doesn’t snap into place and do the right thing!

Most crashes will be very similar to this. Something will be impossible, and the mistake will be somewhere else. Looking at the impossible situation will tell what’s wrong about it when comparing to what was meant, and that would be something to follow to the cause, whatever it is, regardless of what it is.

If you can follow the error message to the cause here, then you can do the same things for most other crashes you will ever get.

I give up.

if you wanted to be helpful here the response would be WHY shifting the code around made it work.
That is - is there a rule to the structure of classes and methods that may have been helpful? This is fairly clear when there is inheritance involved but may not be in other cases.

Clearly like the flow of a function where you need to indent properly in order to return/iterate or check items at the right time - as not to stop a loop or check from completing - there is a flow to classes and methods that I was having trouble with.

I’m learning - as are others. If that was something explained in an earlier lesson then I did not catch it and it caused me problems.
I’m sure many people do get error message and just post “what is this” immediately. I spent hours trying to track through my code/backtracking/rewriting before I came here for help because I could not figure out a means to following the error messages after much effort. I was unable to figure it out on my own and did not want to jump to the answer key.

If you are looking to provide feedback and help for anyone else that may be looking through this thread then answering that WHY would definitely be a good place to start.

Otherwise, thank you anyway.

Nothing’s supposed to be indented some particular way. You’d indent things to specify whether or not something should or shouldn’t be in loop or function or class or whatever. But that’s all something you’d do very intentionally.

Shuffling things around doesn’t have bug fixing powers.

If something needed to be indented differently, then that would be something where you could observe incorrect behaviour. You’d be able to say “oh yeah, this part is supposed to be part of the loop”

I did state my guess on why it would seem to fix things. You may have stopped running some code that wasn’t right, and not running it would make it not crash. Doesn’t make it right, though.

Sorry for butting in, but I have an observation to make regarding a few of your posts. You’ve mentioned inheritance a few times, but if you’ve followed the instructions for the project, none of the three classes inherit from each other. When finished, you should have a Business class, a Franchise class and a Menu class. The Business class has a property with a list of instances of the Franchise class assigned to it. Likewise with the Franchise class. It has a property with a list of Menu class instances assigned to it.

The only way I can see that moving things around in your code would have made a difference would be if you had tried to instantiate a new member of a class prior to its definition. Something like:

a = foo("bar")

class foo:
    def __init__(self, param):
        self.prop = param

print(a.prop)

Feel free to post your code if you’d like feedback.

the indenting was an example of how the structure could affect your code in a big way…

This is true as you know what you are doing - ask someone who is just starting out to trouble shoot this problem - the concept of “this is supposed to be part of the loop” may not make sense if you don’t understand how ‘return’ would cause your loop to stop or continue based on that indentation.

if my code is exactly the same as the codecademy answer and is incorrect - then that’s another problem all together.

You’d learn what a loop looks like before moving on to classes.
And that would be one of the first things you learn about a loop. The stuff to repeat is indented under the loop header.

If you combine a bunch of things you don’t know what they do then you get a whole lot of nothing.

If you learn small things like loops and variables and assignment then you can meaningfully combine them in a controlled manner to make bigger things like computing a sum

Midlindner - Do not apologize. Thank you so SO SO much for butting in and providing this feedback.
I don’t have the code that was an issue anymore since I corrected it but basically I think what you are saying may have been my issue without realizing it.
…and is more along the lines of the help i was looking for hours ago haha :slight_smile:

I had only gotten up to the Franchise part at this time so i had Menu and Franchise class
but my order was

class Menu
init
methods
menu objects

a list of the menus

class Franchise
init
methods
franchise objects

the fix was to move all of the menu objects, the list of menus and everything else that wasn’t a class or method for menu or franchise under franchise and its methods

i did the same with business class and the additional arepa information.

Well, if your code followed the pattern you’ve shown, I don’t see an issue. You would have created Menu objects after defining the Menu class, and created Franchise objects after defining the Franchise class. Something else would have had to been amiss.

so you moved things that are not part of franchise…into the definition of franchise? and maybe you even moved it into a method and then never called that method

you might be saying that you are not running the code, and therefore it cannot crash and is as such fixed.
deleting all the code has the same effect as that.

You may be right! I just tried to move some things around but it didnt reproduce my error again. You are right though - creating an object before the class gives the error that it’s not defined. I was not seeing those errors though.

From the issues I was experiencing I’d guess that class Menu was doing something with the menus and Franchise was utilizing them out of order causing some issues with self?

no ionatan - the move fixed the issue. The code runs fine and passes the project tests. We covered this earlier.

there aren’t any tests to fail so, yeah, it would pass them, I guess?

If you want to post your code, we might be able to determine what happened. If you’re satisfied with the project, and want to leave it as is, that’s fine too, but you may be missing out on a valuable learning opportunity especially with @ionatan involved. I’ve learned tons from his contributions to the forums.