0
Differentiate between: list and string
2 odpowiedzi
+ 6
Here is an additional explanation of the datatype "list". In contrast to the data type string, which can contain letters, numbers, special characters and spaces, a list can contain various other data types. So you can see a list as a container.
list containing:
(the items or elements of a list can be a collection of any data type:
- numbers as int and float: [1, 3, 7.24, 3.14, 9]
- strings: ["paul", "simon", "artist"]
- tuple, set, dictionary: [(1, 23), {13, 47, 0}, {"a": 7, "b": 11}]
- or: [3, 12, "hello", [66, 12], ("C++", 12750)]
+ 3
Contents of a list are wrapped in square bracket pair [ and ]
A list is a mutable object.
Contents of a string are wrapped in either single quotes or double quote (can be in triple quotes too).
A string is an immutable object.