January 22nd, 2013, 06:33 AM
Join Date: Jul 2007
Location: Joensuu, Finland
Originally Posted by Dried Monkey
x = 1
y = 1
sx = str(x)
sy = str(y)
equation = sx + " * " sy + " = " str(sx * sy)
while x <= n:
while y <= x:
Y += 1
x += 1
y = 1
What is causing this?
It doesn’t matter how many times you change the values of x and y, because when the value of the variable “equation” was set, x and y were both 1.
Anyway, if I may suggest some ideas:
- it is usually unnecessary to have separate variables for numeric values and their printable counterparts; just use print formatting (.format() or the older % method)
- it’s usually bad practice to create results and produce output in the same function; in most cases it’s more convenient to have one function produce results and another to print the output.
My armada: openSUSE 12.3 (home desktop, laptop, work desktop), Ubuntu 12.04 LTS (mini laptop), Debian GNU/Linux 7.0 (server), Mythbuntu 12.04 LTS (HTPC), Bodhi Linux 2.0 & Windows 7 Ultimate (test desktop), FreeBSD 9.1 (test server)