[Tutor] Final review
Chris “Kwpolska” Warrick
kwpolska at gmail.com
Thu May 1 12:07:09 CEST 2014
On Thu, May 1, 2014 at 7:21 AM, Scott W Dunning <scott.w.d at cox.net> wrote:
> Hello, I am new to python and have a final review coming up and was hoping you could help me answer a few questions I came across while studying.
>
>
> So, I get a little confused about lists sometimes. This one is a little hard to make heads or tails of. I get confused about how to tell how many lists are within one list like the one below. How many lists are located inside alist is it 1 or 2, 3??
Two: [56, 57, "dog"] and [] (empty).
> Also, do spaces count as an index in lists?
What do you mean by “spaces”, exactly?
>>>> alist = [3, 67, "cat”, [56, 57, “dog”], [], 3.14, False]
alist contains:
0. the integer 3
1. the integer 67
2. the string "cat" ¹
3. the list:
0. the integer 56
1. the integer 57
2. the string "dog" ¹
4. an empty list
5. the float 3.14
6. the boolean False
¹ Your e-mail client uses smart quotes and thus mangles your replies
(it converts U+0022 QUOTATION MARK into U+201C LEFT DOUBLE QUOTATION
MARK and U+201D RIGHT DOUBLE QUOTATION MARK, which are not valid
delimiters for Python strings).
> The ouput for below is 2 when it seems like there should be 3 lists located inside x. Is it [10,20] that is not consider inside of x? Any tips on how to tell how to spot them more clearly?
There are two lists in x, and one more list inside a list inside of x:
> x = ['a', [2.0, 5, [10, 20]]]
x contains:
0. the string 'a'
1. the list:
0. the float 2.0
1. the integer 5
2. the list:
0. the integer 10
1. the integer 20
--
Chris “Kwpolska” Warrick <http://kwpolska.tk>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
More information about the Tutor
mailing list