While loop help

Joel Goldstick joel.goldstick at gmail.com
Tue Apr 9 12:36:57 EDT 2013


On Tue, Apr 9, 2013 at 12:24 PM, <thomasancilleri at gmail.com> wrote:

> For system version I get this:
> 2.7.2 (default, Oct 11 2012, 20:14:37)
> [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]
>
> Also, I understand what your saying about the continuation code. There's
> no need for me to include it in each if/else statement, I could just use it
> at the end of the program outside of the statements and it would run no
> matter what. But, what I don't understand exactly is the while statement.
> I've been looking around a lot lately and notice that people say to use for
> instance:
>
> while restart: or while true: or while restart = true:
>
> What makes a statement true? Is there a way to return a true or false
> message. My method was to ask the user to type "true" and if that print
> statement matched restart = "true" then the loop would continue but i
> imagine there is a better way then matching strings and integers like i
> have been.
>
> Also what confuses me is that python doesn't use brackets. How do I
> contain all of my if/else statements into one while loop? Do I have to
> indent each line of code and extra indentation? I'm used to highschool
> doing c++ and java when I would just say:
>
> Python uses indentation.  Most people set their editor to indent 4 spaces
for each level.  It seems odd to people coming from braces languages, but
you get used to it, and it makes code very readable.

As to True/False.  There is a boolean type and its values are True and
False (note the capital letter).  But other values can be considered
True/False.  For instance 0 is considered false, and empty string is
considered false.  Any other number is considered true as is any string
that isn't empty.  Empty sequences are considered false (Tuples, lists)

> while (x<3)
> {
>      if ()
>     else ()
> }
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130409/68f37c2a/attachment.html>


More information about the Python-list mailing list