raw_input passing to fun

G

Gary Wessle

the output of this code below is not what one would expect, it outputs
all kind of numbers and it never stops, I want to ask the user for a
number and then print out the multiplication table up to that number.

thanks

****************************************************************
import math

def printMultiples(n, hight):
i = 1
while i <= hight:
print n*i, '\t',
i = i + 1
print


def printMultTable(hight):
i = 1
while i <= hight:
printMultiples(i, i)
i = i + 1

num = raw_input ("produce a multiplication table up to: ")
printMultTable(num)
****************************************************************
 
J

John Machin

the output of this code below is not what one would expect, it outputs
all kind of numbers and it never stops, I want to ask the user for a
number and then print out the multiplication table up to that number.

That's what you want, but not what you did. You asked them for a string.
thanks

****************************************************************
import math

Not used.
def printMultiples(n, hight):
i = 1
while i <= hight:
print n*i, '\t',
i = i + 1
print


def printMultTable(hight):
i = 1
while i <= hight:

Temporarily, insert here:
print "types:", type(i), type(hight)
print "values:", i, hight
if i > 100: return
printMultiples(i, i)
i = i + 1

num = raw_input ("produce a multiplication table up to: ")
printMultTable(num)

Try this: printMultTable(int(num))

You may wish to consider changing "hight" to "height" :)
 
G

Gary Wessle

John Machin said:
That's what you want, but not what you did. You asked them for a string.


Not used.


Temporarily, insert here:
print "types:", type(i), type(hight)
print "values:", i, hight
if i > 100: return


Try this: printMultTable(int(num))

You may wish to consider changing "hight" to "height" :)

thank you
 

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

Members online

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,200
Latest member
SCPKatheri

Latest Threads

Top