Lesson Number One - just a question



So i got stuck on Lesson Number One and went to Q&A and found this post

Mod said and quote:


"name": = "Lloyd",

a colon or a equal sign, which one is it? I can tell you, its not both

My question is, why the equal sign? Is it because its a string?

Im confused because in the example they have colons.

animal_sounds = {
    "cat": ["meow", "purr"],
    "dog": ["woof", "bark"],
    "fox": [],
print animal_sounds["cat"]

Is it because it as more than one string?


Lets understand it..
When you want to save something (data) inside a variable you use > =
But when You build a dictionary..

You put them in this way--

key : value

You don't use =

One step further...

= puts value inside the variable.
: makes two things related to each other.


@jul140 No where in that post does he (I mean Stetim94 who was the mod referred to) say it is the equal sign he just says it can't be both the equal sign and colon. So it is up to you to figure out which one it really is. Obviously the person making the question felt that both were necessary so he or she put both in his or her code. And as @greentreemee points out it can't be = it must be a :


Its just an example. It was =.


Thank you.
That one step further made everything clear.


Tell you what? It's a great question!!...
Okay the meaning of colon gets changed depending upon sitiuations..

But assignment always means "something getting saved in the variable", Its an operator but colon is not an operator!
so meaning of colon changes! Explore more and learn more, if you find something cool, do share :slight_smile:
Keep up the good work. :thumbsup:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.