January 22nd, 2013, 07: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 13.1 (home desktop, home laptop), Ubuntu 13.04 (work laptop), FreeBSD 9.2 (server), Mythbuntu 12.04 LTS (HTPC), Bodhi Linux 2.0 & Windows 7 Ultimate (test desktop), Android 4.1.2 (tablet)