I copied and ran the following script:
multiplier = 12
for j in range(1,13):
print "%d x %d = %d" %(j, multiplier, j*multiplier)
That ran perfectly and gave me the 12 times table.
I then decided that it would be fun to branch out and make teh
script "universal", so I wrote and ran:
print "Which times table do you want?"
multiplier = raw_input ()
for j in range(1,13):
print "%d x %d = %d" %(j, multiplier, j*multiplier)
The j in range section of code is identical, but I now get:
lisi@Tux:~/Python$ python multiplier.py
Which times table do you want?
4
Traceback (most recent call last):
File "multiplier.py", line 8, in <module>
print "%d x %d = %d" %(j, multiplier, j*multiplier)
TypeError: int argument required
lisi@Tux:~/Python$
What extra should I have done because the variable value came from the
keyboard, and why is it different from the first example?
Lisi
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor