% operation

D

Daewon YOON

====
Python 1.5.2 (#1, Jul 5 2001, 03:02:19) [GCC 2.96 20000731 (Red Hat
Linux 7.1 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam.... z%9
File "<stdin>", line 2
z%9
^
SyntaxError: invalid syntax

====
What's wrong with the above operation and how can I get the correct
modulo result with Python?
 
C

Christopher Koppler

====
Python 1.5.2 (#1, Jul 5 2001, 03:02:19) [GCC 2.96 20000731 (Red Hat
Linux 7.1 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam... z%9
File "<stdin>", line 2
z%9
^
SyntaxError: invalid syntax

====
What's wrong with the above operation and how can I get the correct
modulo result with Python?

There's nothing wrong with the operation, but it looks like you forgot to
indent your loop body (which the interactive shell doesn't automagically
do for you):
.... z%9
....

[result snipped]
 
R

Rick Holbert

It also looks like you are using an old version of Python running on an old
version of Linux. Time to upgrade?

Christopher said:
====
Python 1.5.2 (#1, Jul 5 2001, 03:02:19) [GCC 2.96 20000731 (Red Hat
Linux 7.1 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
x=9
y=4
x%y 1
for z in range(44):
... z%9
File "<stdin>", line 2
z%9
^
SyntaxError: invalid syntax

====
What's wrong with the above operation and how can I get the correct
modulo result with Python?

There's nothing wrong with the operation, but it looks like you forgot to
indent your loop body (which the interactive shell doesn't automagically
do for you):
... z%9
...

[result snipped]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top