Getting started with IDLE and Python - no highlighting and no execution

soloflyr at gmail.com soloflyr at gmail.com
Thu Aug 9 09:36:34 EDT 2012


On Sunday, August 5, 2012 7:46:54 PM UTC-4, PeterSo wrote:
> I am just starting to learn Python, and I like to use the editor
> 
> instead of the interactive shell. So I wrote the following little
> 
> program in IDLE
> 
> 
> 
> # calculating the mean
> 
> 
> 
> data1=[49, 66, 24, 98, 37, 64, 98, 27, 56, 93, 68, 78, 22, 25, 11]
> 
> 
> 
> def mean(data):
> 
> 	return sum(data)/len(data)
> 
> 
> 
> mean(data1)
> 
> 
> 
> 
> 
> There is no syntax highlighting and when I ran it F5, I got the
> 
> following in the shell window.
> 
> 
> 
> 
> 
>  >>> ================================ RESTART
> 
> ================================
> 
> >>>
> 
> >>>
> 
> 
> 
> 
> 
> Any ideas?
> 
> If I added print mean(data1), it gave me a invalid syntax
> 
> 
> 
> # calculating the mean
> 
> 
> 
> data1=[49, 66, 24, 98, 37, 64, 98, 27, 56, 93, 68, 78, 22, 25, 11]
> 
> data2=[1,2,3,4,5]
> 
> 
> 
> def mean(data):
> 
> 	return sum(data)/len(data)
> 
> 
> 
> mean(data1)
> 
> print mean(data1)

did you call you file xxx.py  IDLE looks for the .py extension to identify the program as python code.



More information about the Python-list mailing list