Beginnger Question

Terry Reedy tejarex at yahoo.com
Tue Apr 9 10:44:17 EDT 2002


"Dennis" <dennis at horsethieves.com> wrote in message
news:c4a65c5f.0204090624.710228ff at posting.google.com...
> If there's a better forum for asking newb questions, please point me
> there!

There is (or at least has been) a beginner tutorial email list: see
python.org

> I'm new to programming.  My only experience up to this point is some
> aborted attempts to learn C and Java.  I'm finding Python much
easier
> to learn than those.

Welcome to the club.

>  Currently, I'm pushing my way through
> "Non-Programmers Tutorial for Python" by Josh Cogliati.
> My current problem is this:
>
> x = 2
>
> def wrong(num):
>     return num + 1
>
> print wrong(x)
> print wrong(x)
>
> I cannot figure out why this (simplified) program won't increment x
> and produce 3 and 4.

Ask yourself why you expect it to and then tell yourself, "There is
something wrong with that reasoning."  (Hint: num+1 generates a new,
unnamed object.)

>  This is probably indicative of a bigger problem
> with understanding functions (and their limitations).

Keep experimenting until you understand better.  Put print statements
inside functions.

Terry J. Reedy






More information about the Python-list mailing list