# Error or I'm I not learning the basics

So thanks for this it seemed to be a great way to learn something new so I tried it.
I’ve only just started and either I’m not learning or there is an error.

![Screenshot_20180423-064802|281x500]

Should it not have been y for the answer? This is the second in a row I got wrong and they were both the same type of questions.
Can any one explain why my answer is wrong. I must be missing something.
Thanks

Unfortunately, this is not a bug, but it’s definitely a bit of a tricky concept when first starting out, so I’ll do my best to try and clear things up. Here’s an explanation from a different post:

But if you’d like me to go more in-depth about variables, feel free to reply! 1 Like

That seems off to me.
I’ve read this a dozen times, maybe I am not cut out for programming if this stumps me.
It says in the image attached
QUOTE" When print (x) runs it looks inside the variable called x and prints out the value its holding. In this case, the variable x is holding the value 5 (not from what i see it is holding y) so that is what gets printed out."

var y = 5;
var x = y;
if print(x) is called is this not asking to know what is in var x? why the heck would it print 5 if it is holding y?

Once you get past the learning curve, it’ll come naturally. It’s like learning a new language.
`x = 5;` because y is given the value of 5 and then x is given the value of y (5). One way to look at this is:
x = y = 5
Both x and y are variables that store certain data (numbers, strings, etc.), but if a variable(x) tries to store another variable(y), then the variable(x) copies the value(5) of the other variable (y).

This allows you to change the value in y while keeping the original value in x in case you ever want to go back to it. Such as:

``````var y = 5;
var x = y;

y = y + 2;

print(y); //y = 7
print(x); //x = 5
``````

Hope this did a better job, but feel free to reply if otherwise! 2 Likes

Because this is similar to how the answer in the prior quiz LOOKED and you’re new to this, I think that’s why it’s confusing.

(Image of previous quiz)

The variables listed here are STRINGS (because they are in quotation marks) and print is asking for ALPHABET not in quotation marks.

In your quiz, print is asking for for X whose value is the variable Y — because x’s variable is NOT A STRING.

So you need to watch for those quotation marks and ask: is it asking for the string or for a variable?

3 Likes

I read ALMOST all the answers — you nailed it and I wasted everyone’s time 1 Like

This sounds like a case where a drawing or even a video of the traditional post office box analogy (one labeled `x`, and another labelled `y`, with pieces of paper showing a `5` – except you can’t remove the paper from the box, just copy it) might be helpful.

Thank you! The light bulb over my head went on after reading your explanation. I had the same question. Hey there, let’s look at it line by line.

The first line declares a variable named `y`. This variable stores the value `5`.
The 2nd line declares a variable named `x`. This variable is set to `y`. Because `y` has the value `5`, `x` now has the value `5`.

Let me know if you have any questions!
Ben

A better way to explain it is to look at the datatype of x’s value.
`var y = 5;`
This line creates a variable called `y` and assigns it a value of `5`.
`var x = y;`
This line creates a variable called `x` assigns it a value of `y`. Since `y` is not a string, `x` is not equal to `'y'`. The only way `y` could be the value is with a string, which would require `'y'`. Therefore, `x` gets assigned the value `5`.
`print(x);`
This prints out the variable `x`, which is assigned the value `5`.

1 Like

That’s what I was saying!