...
| Code Block |
|---|
strings = "my name is Chun Kang and Chun is my name" r = set(strings.split()) print(r) |
Python List REPL sessions
| Code Block |
|---|
a = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge']
print(a[:] is a)
print(max(a[2:4] + ['grault']))
print(a[-5:-3])
print(a[-6])
print(a[4::-2]) |
Diagram for the list indices:
| 'foo' | 'bar' | 'baz' | 'qux' | 'quux' | 'corge' |
|---|---|---|---|---|---|
| 0 | 1 | 2 | 3 | 4 | 5 |
| -6 | -5 | -4 | -3 | -2 | -1 |
Result
| Code Block |
|---|
False
qux
['bar', 'baz']
foo
['quux', 'baz', 'foo'] |
Tuple
| Info |
|---|
The tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets. |
...