[perl-python] 20050114 if statement
Reinhold Birkenfeld
reinhold-birkenfeld-nospam at wolke7.net
Sat Jan 15 02:39:22 EST 2005
Xah Lee wrote:
> . # here's an example of if statement in python.
> .
> . x=-1
> . if x<0:
> . print 'neg'
> . elif x==0:
> . print 'zero'
> . elif x==1:
> . print 'one'
> . else:
> . print 'other'
> .
> . # the elif can be omitted.
> . ------------------------------
> . # here's an example of if statement in perl
> .
> . $x=31;
> . if ($x<0) {
> . print 'neg'
> . } elsif ($x==0) {
> . print 'zero'
> . } elsif ($x==1) {
> . print 'one'
> . } else {
> . print 'other'
> . }
Note that Perl's print doesn't append a newline to the printed string.
Reinhold
More information about the Python-list
mailing list