Hello daniweb community,
i'm new to all this and i'm pretty happy that found this. Anyway i'm having sevral issues. Frist one is: my Python GUI (IDLE) won't open program.

def num(n):
    count=0
    while count <= abs(n):
	count = count + 1
	n= abs(n)/10
	print count
num(-23)

This code is problem. It's quite odd, but when i copy it at www.codepad.org, and try output
it's working fine. However, if i open it from notepad ++ (choosing to rn that python gui idle), and doesn't show any output in python active shell. (and this working for other programs well).
EDIT:
updated program so it works with negative values

Edited 5 Years Ago by paramaster: n/a

Hello daniweb community,
i'm new to all this and i'm pretty happy that found this. Anyway i'm having sevral issues. Frist one is: my Python GUI (IDLE) won't open program.

def num(n):
    count=0
    while count <= abs(n):
	count = count + 1
	n= abs(n)/10
	print count
num(-23)

This code is problem. It's quite odd, but when i copy it at www.codepad.org, and try output
it's working fine. However, if i open it from notepad ++ (choosing to rn that python gui idle), and doesn't show any output in python active shell. (and this working for other programs well).
EDIT:
updated program so it works with negative values

I tried your code in IDLE, and it was rejected because of inconsistent indentation. You must not mix tab characters and spaces to indent python code. Configure your editor to insert 4 spaces instead of a tab when you hit the tab key. Here is the same code indented with spaces and it works

def num(n):
    count=0
    while count <= abs(n):
        count = count + 1
        n= abs(n)/10
        print count
num(-23)

In IDLE, it's: options -> configure idle -> Fonts/Tabs -> Indentation Width -> 4 .

Edited 5 Years Ago by Gribouillis: n/a

This article has been dead for over six months. Start a new discussion instead.