[Courses] [python] Lesson 2: Loops, if, and beer
Leslie
leslie.brothers at verizon.net
Sat Jun 25 01:04:25 UTC 2011
Two questions from this lesson:
>
> At the Python >>> prompt, try typing:
> range(10, 2)
> [2, 4, 6, 8]
I didn't get that. I got:
>>> range(10, 2)
[]
>>>
What gives?? I did not get [2, 4, 6, 8]
However, if I typed
range (10, 2, -2), I got [10, 8, 6, 4]
>
> for i in range(1, 6) :
> if i == 3 :
> print "i is three!"
> elif i == 4 :
> print "now it's four!"
> else :
> print "Hello, world! i =", i
This question is about interactive (console) Python.
I entered the above but had a typo in the first line so I got an error
message. Is there a way to correct a line retroactively when you are in
interactive Python (>>>) mode -- so you don't have to just enter the
whole thing all over again?
Thanks,
Leslie
>
More information about the Courses
mailing list