+ 1

In a list, what are the elements defined as if we dont specify them?

list = [1, 2, w, ] so in this example would the elements be considered strings or not?

20th Nov 2017, 2:02 PM
Matt Huynh
Matt Huynh - avatar
8 odpowiedzi
+ 7
you can try it in code playground :)
20th Nov 2017, 2:16 PM
jay
jay - avatar
+ 6
you mean: list = [1, 2, "w"] right?
20th Nov 2017, 2:08 PM
jay
jay - avatar
+ 6
The list is a most versatile datatype available in Python which can be written as a list of comma-separated values (items) between square brackets. Important thing about a list is that items in a list need not be of the same type.
20th Nov 2017, 2:11 PM
jay
jay - avatar
+ 3
sorry! i done errors in my last post! i am checking it.
24th Nov 2017, 4:04 AM
Vitalij Bredun ♡ Python Petersburg
Vitalij Bredun ♡ Python Petersburg - avatar
+ 2
if you multiple a list to 3 would the outcome be [1, 2, "w"][1, 2, "w"][1, 2, "w"]?
20th Nov 2017, 2:14 PM
Matt Huynh
Matt Huynh - avatar
+ 2
[ERORR] 2*[w]==[w][w] # True. w - isn't a letter, is a variable 2*["v"]==["v"]["v"] # True 'v' - is a letter
20th Nov 2017, 2:44 PM
Vitalij Bredun ♡ Python Petersburg
Vitalij Bredun ♡ Python Petersburg - avatar
+ 2
okay thanks for all the help guys !! I'm understanding it more now
20th Nov 2017, 5:54 PM
Matt Huynh
Matt Huynh - avatar
+ 2
[TRUE] w="v" 2*[w]==[w, w] # True or 2*["v"]==["v", "v"] # True too Test it pls: w="v" b = 2*[w] c = [w, w] print(b==c) # True print(b) b=2*["v"] c=["v", "v"] print(b==c) # True print(b) Please check and report me a bug;)
24th Nov 2017, 4:44 AM
Vitalij Bredun ♡ Python Petersburg
Vitalij Bredun ♡ Python Petersburg - avatar