Re: [Tutor] Final review

2014-05-08 Thread Steven D'Aprano
On Wed, May 07, 2014 at 08:49:11PM -0700, Scott W Dunning wrote: [...] > > >>> greeting [len(greeting)] > > > > It is trying to access the character at the position "11", where the > > string "Hello world" doesn't contain any value in the index "11" and > > the maximum index is 10. So it throws

Re: [Tutor] Final review

2014-05-07 Thread Danny Yoo
On Wed, May 7, 2014 at 8:49 PM, Scott W Dunning wrote: > > On May 5, 2014, at 10:13 PM, meenu ravi wrote: > >> Likewise, the index of d, which is the last word in the word "Hello world" >> is 10. >> >> So, the maximum index you can access in the word "Hello world" is 10. But >> when you try to

Re: [Tutor] Final review

2014-05-07 Thread Scott W Dunning
On May 5, 2014, at 10:13 PM, meenu ravi wrote: > Likewise, the index of d, which is the last word in the word "Hello world" is > 10. > > So, the maximum index you can access in the word "Hello world" is 10. But > when you try to give the command, > > >>> greeting [len(greeting)] > > It is t

Re: [Tutor] Final review

2014-05-07 Thread Steven D'Aprano
On Tue, May 06, 2014 at 06:36:21PM +0100, Alan Gauld wrote: > Aside: > len() does work with range() and slicing so you can write > > myList[:len(mylist)] > > to get a copy of your list... Even easier is a blank slice. The start defaults to zero, the end to the length of the sequence, and the s

Re: [Tutor] Final review

2014-05-06 Thread Alan Gauld
On 06/05/14 04:43, Scott Dunning wrote: I have another question. I don’t understand why below would give an error? greeting = 'Hello World' greeting [len(greeting)] Because list indexing starts at zero but len() returns the actual length. So the last element of a list is mylist[len(mylis

Re: [Tutor] Final review

2014-05-06 Thread Danny Yoo
On Mon, May 5, 2014 at 9:04 PM, Scott W Dunning wrote: > > On May 1, 2014, at 5:30 AM, Steven D'Aprano wrote: > > Awesome, thanks everyone! I understand lists a lot better now. > > I have another question. I don’t understand why below would give an error? > greeting = 'Hello World’

Re: [Tutor] Final review

2014-05-06 Thread Scott Dunning
On May 1, 2014, at 5:30 AM, Steven D'Aprano wrote: > Awesome, thanks everyone! I understand lists a lot better now. I have another question. I don’t understand why below would give an error? >>> greeting = 'Hello World' >>> greeting [len(greeting)] __

Re: [Tutor] Final review

2014-05-05 Thread meenu ravi
Hi Scott, The variable greeting is of type "string". >>> greeting = "Hello world" >>> type(greeting) The len(string) will count each character in the value of variable "greeting" starting from '1'. H - 1 e - 2 l - 3 l - 4 0 - 5 space - 6(Space and special characters are also counted)

Re: [Tutor] Final review

2014-05-05 Thread Scott W Dunning
On May 1, 2014, at 5:30 AM, Steven D'Aprano wrote: Awesome, thanks everyone! I understand lists a lot better now. I have another question. I don’t understand why below would give an error? >>> greeting = 'Hello World’ >>> greeting [len(greeting)] _

Re: [Tutor] Final review

2014-05-04 Thread Matt Harris
> 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? > > x = ['a', [2.0, 5, [10, 20]]] > print len(x) Hey Scott Here, it looks like x is a list cont

Re: [Tutor] Final review

2014-05-01 Thread Mark Lawrence
On 01/05/2014 06:21, Scott W Dunning 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.

Re: [Tutor] Final review

2014-05-01 Thread Steven D'Aprano
On Wed, Apr 30, 2014 at 10:21:41PM -0700, Scott W Dunning wrote: > 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

Re: [Tutor] Final review

2014-05-01 Thread Chris “Kwpolska” Warrick
On Thu, May 1, 2014 at 7:21 AM, Scott W Dunning 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 ma