This shows you the differences between two versions of the page.
|
ii:labs:02:tasks:01 [2021/11/07 23:10] radu.mantu |
ii:labs:02:tasks:01 [2024/10/25 01:48] (current) radu.mantu |
||
|---|---|---|---|
| Line 154: | Line 154: | ||
| ... "and his comrades would chuckle at the sheer treason of it." | ... "and his comrades would chuckle at the sheer treason of it." | ||
| - | >>> the length of the string can be obtained using len() | + | >>> # the length of the string can be obtained using len() |
| >>> len(s) | >>> len(s) | ||
| 230 | 230 | ||
| Line 325: | Line 325: | ||
| >>> list(t) | >>> list(t) | ||
| ['pi', 3.1415, True] | ['pi', 3.1415, True] | ||
| - | >>> list(t) + [ '3', .5772, True ] | + | >>> list(t) + [ 'e', 2.7182, True ] |
| - | ['pi', 3.1415, True, '3', 0.5772, True] | + | ['pi', 3.1415, True, 'e', 2.7182, True] |
| >>> # similarly, a tuple can be generated from a list | >>> # similarly, a tuple can be generated from a list | ||
| - | >>> tuple(list(t) + [ '3', .5772, True ]) | + | >>> tuple(list(t) + [ 'e', 2.7182, True ]) |
| - | ('pi', 3.1415, True, '3', 0.5772, True) | + | ('pi', 3.1415, True, 'e', 2.7182, True) |
| >>> # tuples can be used as a shortcut to assign multiple values at once | >>> # tuples can be used as a shortcut to assign multiple values at once | ||