>>> l = [1,'b', [3,4.],5,6]
>>> t = (8,9, ['a',1],4,5)
>>> l = list(t); t = tuple(l)
>>> type(l), type(t)
>>> l, t
([8, 9, ['a', 1], 4, 5], (8, 9, ['a', 1], 4, 5))
>>> l = [1,'b', [3,4.],5,6]
>>> s = range(20)
>>> s
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> i = iter(t); i.next()
8
>>> l[2][1],l[-3][-1]
(4.0, 4.0)
>>> s = 'what a nice day!'
>>> '-' * 5
'-----'
>>> len(s), s[2:5], s[:], s[4:], s[4], s[:-2]
(16, 'at ', 'what a nice day!', ' a nice day!', ' ', 'what a nice da')
>>> s[1:3:2], s[::2], s[::-1]
('h', 'wa iedy', '!yad ecin a tahw')
>>> max(s), min(s), 'a' in s, 'a' not in s
('y', ' ', True, False)
>>> s
'what a nice day!'
>>> s.index('a'), s.count('n')
(2, 1)
>>> l
[1, 'b', [3, 4.0], 5, 6]
>>> l.append(':)')
>>> l
[1, 'b', [3, 4.0], 5, 6, ':)']
>>> l.pop()
':)'
>>> l1=[2,2,34]; l.append(l1)
>>> l
[1, 'b', [3, 4.0], 5, 6, [2, 2, 34]]
>>> l.extend(l1)
>>> l
[1, 'b', [3, 4.0], 5, 6, [2, 2, 34], 2, 2, 34]
>>> l.insert(2,'@@'); l.remove(2)
>>> l
[1, 'b', '@@', [3, 4.0], 5, 6, [2, 2, 34], 2, 34]
>>> l.reverse()
>>> l
[34, 2, [2, 2, 34], 6, 5, [3, 4.0], '@@', 'b', 1]
>>> l.sort()
>>> l
[1, 2, 5, 6, 34, [2, 2, 34], [3, 4.0], '@@', 'b']
>>> t = (8,9, ['a',1],4,5)
>>> l = list(t); t = tuple(l)
>>> type(l), type(t)
([8, 9, ['a', 1], 4, 5], (8, 9, ['a', 1], 4, 5))
>>> l = [1,'b', [3,4.],5,6]
>>> s = range(20)
>>> s
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> i = iter(t); i.next()
8
>>> l[2][1],l[-3][-1]
(4.0, 4.0)
>>> s = 'what a nice day!'
>>> '-' * 5
'-----'
>>> len(s), s[2:5], s[:], s[4:], s[4], s[:-2]
(16, 'at ', 'what a nice day!', ' a nice day!', ' ', 'what a nice da')
>>> s[1:3:2], s[::2], s[::-1]
('h', 'wa iedy', '!yad ecin a tahw')
>>> max(s), min(s), 'a' in s, 'a' not in s
('y', ' ', True, False)
>>> s
'what a nice day!'
>>> s.index('a'), s.count('n')
(2, 1)
>>> l
[1, 'b', [3, 4.0], 5, 6]
>>> l.append(':)')
>>> l
[1, 'b', [3, 4.0], 5, 6, ':)']
>>> l.pop()
':)'
>>> l1=[2,2,34]; l.append(l1)
>>> l
[1, 'b', [3, 4.0], 5, 6, [2, 2, 34]]
>>> l.extend(l1)
>>> l
[1, 'b', [3, 4.0], 5, 6, [2, 2, 34], 2, 2, 34]
>>> l.insert(2,'@@'); l.remove(2)
>>> l
[1, 'b', '@@', [3, 4.0], 5, 6, [2, 2, 34], 2, 34]
>>> l.reverse()
>>> l
[34, 2, [2, 2, 34], 6, 5, [3, 4.0], '@@', 'b', 1]
>>> l.sort()
>>> l
[1, 2, 5, 6, 34, [2, 2, 34], [3, 4.0], '@@', 'b']
Comments
Post a Comment