Hi Ryan, I see what confused you; the
" >>> number + 1 6 >>> print number 5 " part. Yeah, it's only evaluating the the first one. So you're asking it "What's number + 1"? Whereas, >>> number = number + 1 or >>> number += 1 Is saying "Make number equal number plus 1" Ha, it's all a learning experience. Regards, Liam Clarke On 4/21/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > > But when i use a number = number + 1 > > right after the value stays the same, > > I'm not sure what you mean by that. > > > Now i thought that number = number + 1 just wasn't > > vailed in python untill i tried it again and it > > worked, > > variable = variable + 1 > > is perfectly valid. It is not the normal math meaning of an equation > however, it is an assignment statement. In a language like Smalltalk > or Pascal they use a different symbol (:=) for assignment which > is IMHO A Good Thing(TM) And they traditionally read that > symbol as "becomes", thus: > > variable := variable + 1 > > is read: "variable becomes variable plus one" > > What it means is that variable takes on the previous value > of variable plus one. So if it starts as 42 it ends as 43 > > This is such a common thing to do that Python actually > has a shorthand for it: > > variable += 1 > > And after all that, I've just realised that I don't discuss this > at all in my tutorial so I need to add an explanation this weekend. > So thanks for asking the question! :-) > > HTH, > > Alan G > Author of the learn to program web tutor > http://www.freenetpages.co.uk/hp/alan.gauld > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor