Modulok wrote:
> if number <= 10 and number >= 1:
I like that you can spell that
if 1 <= number <= 10:
in Python.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
It's easier to ask for forgiveness than permission. Ask yourself "Is this an
action that could fail in a specific way?" If yes, you need try/except. If no,
you probably need if/else. When dealing with data such as user input or opening
files and so forth, use try/except. When those actions fail, th
On 25-Jan-12 19:49, Devin Jeanpierre wrote:
On Wed, Jan 25, 2012 at 10:36 PM, Michael Lewis wrote:
if number>=0 or< 0:
As long as we're helping with this, I'll just add a comment about this
conditional statement. First, if you string together two expressions
with "or" between them, t
On Wed, Jan 25, 2012 at 10:36 PM, Michael Lewis wrote:
> Is it generally better to use try/except/else statements or if/elif/else?
> Or, is there a time and place for each?
There's a time and place for each. Most errors are indicated in the
form of an exception being raised, though.
> For a simp
Hi everyone,
I am new to python and have a noob question.
Is it generally better to use try/except/else statements or if/elif/else?
Or, is there a time and place for each?
For a simple example, assume I want a user to enter a number
1) try:
number = float(input('enter a number: ')
exc