954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

indentation error

Hi,
This is the existing code:

for c in chartNames:            
		chartUrl = baseChartUrl+c
		hd = extractChart(chartUrl)
		
		writeChart(hd,c)		

		for key in hd:			
			if key in chart:
				chart[key].append(c)
			else:
				chart[key] = [c]


when i wanted to insert a line before

chartUrl = baseChartUrl+c


by putting the cursor to the end of the

for c in chartNames:


and pressing an enter I get compile error.

what's happening here?

johndoe444
Posting Whiz in Training
214 posts since Feb 2008
Reputation Points: 11
Solved Threads: 0
 

1. Can you please make the indentation level to 4 spaces.

2. Please use 'code=python' surrounded by square '[ ]' bracets so that it will be correctly cololur coded and end with '\code' enclosed in the same square brackets. Click on the link below for mode details on code tags
http://www.daniweb.com/forums/misc-explaincode.html?TB_iframe=true&height=400&width=680

OR you can click the link on the right side in the box below called '
Help with Code Tags'

This is what your code should look like:

for c in chartNames:
    chartUrl = baseChartUrl+c
    hd = extractChart(chartUrl)

    writeChart(hd,c)

    for key in hd:
        if key in chart:
            chart[key].append(c)
        else:
            chart[key] = [c]


3. Please provide hard coded values and to the list / tuple / dictionary & variables and function so that it is executable and gives an output or atleast a traceback

rupeshpradhan
Newbie Poster
21 posts since Oct 2004
Reputation Points: 10
Solved Threads: 2
 

what editor do you use?
Get ulipad
http://code.google.com/p/ulipad/

evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
 
by putting the cursor to the end of the for c in chartNames: and pressing an enter I get compile error.

"I get a compile error" is too vague for anyone to figure out. It is probably that the blank line is not indented at the same level as the other lines and your editor does not like that (which is overly picky, but at the discretion of whoever wrote the editor), but as I said it is impossible to decipher without the line number of the error and what it is. Use try/except, especially when testing.

try:
    for c in chartNames:
        chartUrl = baseChartUrl+c
        hd = extractChart(chartUrl)
 
        writeChart(hd,c)
 
        for key in hd:
            if key in chart:
                chart[key].append(c)
            else:
                chart[key] = [c]
except:
    import traceback
    traceback.print_exc()
    raise
woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
 
what editor do you use? Get ulipad http://code.google.com/p/ulipad/


How long have you known about this?
And why haven't you told us until now?!

jlm699
Veteran Poster
1,112 posts since Jul 2008
Reputation Points: 355
Solved Threads: 292
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You