Tsering Choedhen1,050 Points
Why one arguments is within quotes ("Books") and another one is not when display_list function is called?
When display_list function was defined, it was set with two parameters. And now when this function is called, the two arguments passed. But one argument is passed in a quotes (" ") and another one is not. Why and how will we know that when the arguments passed should be in quotes or not?
All problems are best understood with practical examples, so let's make an example code.
Books = ["Harry Potter and the philosophical stone", "Harry Potter and the dungeon of secrets", "Harry Potter and the prisoner of Azerbaijan"] #Let's make a function now def display_list(display_name_of_book_series, the_list_of_books): print(display_name_of_book_series) print(the_list_of_books) #Now let's call the function display_list("Harry Potter", Books)
The points to take from the example are that
1) The double quotes ("") are used to make a string and anything inside the double quotes ("") will be a string.
2) If anything is a string, it will be taken as it is like, literally, for example, if I put (aposkfj3474734''';;;>><<<<mn(sjsjd) [ a, b ,c,c,v,(polo)] into a string it will be as it is, a practical example;
A_string = " (aposkfj3474734';;;>><<<<mn(sjsjd) [ a, b ,c,c,v,(polo)] " print(A_string) #Output (aposkfj3474734';;;>><<<<mn(sjsjd) [ a, b ,c,c,v,(polo)]
So anything inside double quotes("") is untouchable. Strings are like a Black Hole it absorbs everything and anything, what if you want to put double quotes ("") in a string, the principle is very simple just put the double quotes("") into triple quotes (""") and you got a string.
example of string;
A_string = ( """The name of the book is 'Harry Potter' and the name of the character is "Harry" is noob""" ) print(A_string)
3) A variable is a name you give or assign to an object ( an object can be anything, it can be a string, a list, a tuple, a number, a function .....) in this case
Books is a variable or name assigned to a list of book names. Variables need to be assigned to something otherwise they won't work.
#variable # A string Books = "Books"
4) The display_list function takes two parameters and then prints out whatever is passed in, in this case, I passed in "Harry Potter" as a string and Books as a variable
SO in a summary, regarding your question, the
"Books" is just a string and it can be anything you want it to be you can call it
"123455" and it won't make a difference because it's a string the
Books without the double quotes
"" is a Variable and has a value stored in it, so if you put in
Book list the program won't be able to find the name
Book list because the Variable
Book list does not exist.
def display_wishlist(display_name, wishes):
display_nameis just a string, in this case it is
"Books"- that's why we put this in quotes
wishesis the list which is passed in, in this case it is
bookson line 1
Does this help?