Pack Your Bag explainer


#62

I thought I was learning as I was going through this process as I was filling through lessons with no problems. Then I got to the last for steps and it proves I leaned nothing. Really had high hopes for this but feel like it won’t actually help me learn to code with repeating each phase over and over again


#63

Maybe your codes has a bug, check it!


#64

The secret message in the “sample code solution” made me laugh :laughing: as that was a very good answer - to test our knowledge - indeed.


#65

Having a lot of trouble. The button for food is not .food but straight food.


#66

Hey @SelTheDon,

Could you share a screenshot of your code? The extra property within the object shouldn’t block you from completing, so there may be another element that needs to be adjusted and I’d love to help you find it!

H :slight_smile:


#67

Hey @David_Brake,

You might want to take a look at this comment of an example solution for this puzzle to see if you can spot where your code is different.

H :slight_smile:


#68

I’ve read all these threads and I still can’t seem to get past this puzzle. Here is a screenshot of my code. Please help!


#69

Your first line: var myBackpack = 'x'; can be eliminated. This is because you’re immediately overwriting this in your second line, where you declare the myBackpack variable again and assign it an object.

The string 'x' stored in myBackpack is never used in your code.

–Frankie


#70

Thank you so much! I made it work!!!


#71

Stucked.
Error as.

"Your packed your beg.to double check you have got the right food,print out the food properties value, using print(myBackpack.food)

Screen shots can’t be uploaded.
Shows only link of screen shot.


#72

Perhaps you’re printing out a string that says, “myBackpack.food” instead of the food property of the myBackpack object?

There shouldn’t be quote marks around the thing inside your print(). You’ll want to use the print() button, then the myBackpack button, then the .food button.

–Frankie


#73

Hi Heather, could I please get your help? I am not sure if I am messing syntax or something else up


#74

Each of your arrays [] only contains 1 string. For example, the myBackpack.food array has 1 element: the string 'bananas,energy bar'. That is seen a a single item even though it contains a comma and space. Notice there is only one pair of quotes surrounding the string.

You can change that first string to 'bananas', and then on the blank below that add another string using the str key. That will add the orange quote marks so you can type in your second item in the array. You’ll have to do the same for your other 2 arrays as well.

If you need any more help with this puzzle, you can check out the explainer for Get More Supplies.

–Frankie


Get More Supplies explainer
Get More Supplies explainer
#75

Hello @Grasshopper_Frankie

I don’t know why it doesn’t work. Can you help?


#76

Hi,

The only difference in your code is that you have curly brackets around the entire thing. This doesn’t affect how it will run, but it does affect the way we’re checking your code. We generally do this kind of check to make sure the solution isn’t tucked inside of an if statement or a loop.

Unfortunately, you can’t delete the brackets without deleting everything inside too. I would suggest, copying your solution to a new line below the big code block {} and then deleting the whole code block.

–Frankie


#77


Don’t know what I’m doing wrong, I read all the answers


#78

Whats the issue here then.


#79

Similar to the post above, your print() statement is inside of an additional code block {}. If you delete that block and then re-add print(myBackpack.food); it should work.

–Frankie


#80

Your print statement is using the string 'myBackpack.food' instead of the food property of the myBackpack object. Notice how the string is orange and surrounded by quote marks.

If you tap on the string once and then tap the delete button (the back arrow with the X, right below the green play button in your picture), you can remove the string and then insert the myBackpack identifier, and then attach the .food member expression to it.

–Frankie


#81

There is an error in Grasshopper! Just erase all your code and re-enter corrected code and all will be well.