• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need simple python help

importdistributors

Senior member
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))
 
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.
 
Back
Top