+ 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?
8 Answers
+ 7
you can try it in code playground :)
+ 6
you mean:
list = [1, 2, "w"]
right?
+ 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.
+ 3
sorry! i done errors in my last post! i am checking it.
+ 2
if you multiple a list to 3 would the outcome be
[1, 2, "w"][1, 2, "w"][1, 2, "w"]?
+ 2
[ERORR]
2*[w]==[w][w] # True. w - isn't a letter, is a variable
2*["v"]==["v"]["v"] # True 'v' - is a letter
+ 2
okay thanks for all the help guys !! I'm understanding it more now
+ 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;)