+ 2
SOLVED Python. What's the difference between () and []
x = (1,2) y = [1,2] print(x[0]+x[1]) print(y[0]+y[1]) # first n second output is 3 is x array or y is array ? (list or array) I've learnt c++ and this is a confusing
3 Antworten
+ 3
If i remember correctly
() are tuples
[] are lists
https://www.sololearn.com/discuss/1521094/?ref=app
+ 3
Here x is tuple.which is immutable and y is list which is similar to array i say similar not equal means in list you can also hold a different type of data types together but if we talk about array this is not possible in array.and y which is here list also a mutable data type.
Also check this link for more information.
https://www.pythoncentral.io/JUMP_LINK__&&__python__&&__JUMP_LINK-lists-and-tuples/
+ 1
Following Taste 's post, tuples are inmutable, while lists are mutable.