Put it all together - quotation marks


Why is each str. in the list: students = [lloyd, alice, tyler] not in quotation marks?



HI it's because they are dictionary so if you put the " " they will be string..... but they want you to put the dictionary(lloyd,alice,taylor) in a list


Thanks for the answer. But technically couldn't I use a list instead of a dictionary....and when do I use lists rather than dictionaries?
If I wanted to put the names in alphabetic order, wouldn't a list be more appropriate?


Hi if you use a list you will only have names

students = ["lloyd", "alice", "taulor"]

but with dictionary you give some propriety/value

lloyd = {
   "name" : "Lloyd",
   "age": 17

like you can see with the list you can't give any proprity/value like you do with the dictionary..
When to use them ..well it depenf if you want to have any specific information to describe (a person, an object, or something alse..) you will use a list

mark = {
    "name": "Mark",
    "age" : 29,
    "nationality": "Unknow"

but if you doesn't need of spefic information you will use a dicctionary

people = ["Mark", "John", "Snow"]


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