interactive programming
Sean 'Shaleh' Perry
shaleh at valinux.com
Fri Feb 23 14:20:28 EST 2001
On 23-Feb-2001 Chris Richard Adams wrote:
> How can I create a loop - interactively. I'm just trying to learn
> syntax for example, so Id like to create conditional if statements like
> a = 'feb'
>
> if a == 'jan':
> mo = 1
> elif a == 'feb':
> mo = 2
> elif a == 'mar':
> mo = 3
> ...
>
> I tried to type this interactively, but I get a mess of error about
> syntax or mis placed whitespace...
>
$ python
Python 1.5.2 (#0, Feb 20 2001, 23:57:58) [GCC 2.95.3 20010125 (prerelease)] on
linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>
the >>> is the 'start a command here prompt'
>>> if a == 'jan':
... print a # the ... is the 'continue previous command', when you see this
... # you must indent your code (just hit tab or a few spaces)
... elif a == 'feb': # still under the if
... print a # again, indented
...
feb
>>> # back to start a command
More information about the Python-list
mailing list