Need simple python help

importdistributors

Senior member
Sep 14, 2004
294
0
0
I am new with python and am having problems running programs in the new python 3.0

If anyone knows what changes need to be make to help this run, I would appreciate it.

Im getting an error about inconsistent use of tabs and spaces in indentation.

any help would be appreciated.

#!/usr/local/bin/python

import string, sys


# If no arguments were given, print a helpful message
if len(sys.argv)==1:
print ('Usage: celsius temp1 temp2 ...')
sys.exit(0)

# Loop over the arguments
for i in sys.argv[1:]:
try:
fahrenheit=float(string.atoi(i))
except string.atoi_error:
print repr(i), ("not a numeric value")
else:
celsius=(fahrenheit-32)*5.0/9.0
print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5))
 

mundane

Diamond Member
Jun 7, 2002
5,603
8
81
Python is whitespace sensitive - your code *needs* to be indented correctly. Unfortunately, the forum formatting (also including the attached code feature, IIRC) smashes leading whitespace, making it difficult to accurately identify where your code is malformatted.