Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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'
012345
-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.

...