473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

There is an indentation error that says expected an indented block

There 's a indentation error but i don't know what's wrong with it.
the error says

File "./class_question.py", line 12
self.dic = [] #array of hash tables for input data
^
IndentationError: expected an indented block


Expand|Select|Wrap|Line Numbers
  1. #! /usr/bin/env python
  2.  
  3. class Question:
  4.     #constructor    
  5.     dic
  6.     questions
  7.     answers
  8.     qANDa
  9.     vspace
  10.  
  11.     def __init__(self):
  12.        self.dic = []            #array of hash tables for input data
  13.        self.questions = []    #array for all questions
  14.        self.answers   = []     #array for corresponding answers    
  15.        self.qANDa        = []    #array of hash tables
  16.        self.vspace     = "0.4in "
  17.  
  18.    def getRestrictions(self,filename):
  19.        print "Processing",filename
  20.  
  21.    def addquestion(self,questionstring):
  22.        self.questions.append(questionstring)
  23.  
  24.     def addanswer(self,answerstring):
  25.         self.answers.append(answerstring)
  26.  
  27.     def addqANDa(self,questionstring, answerstring):
  28.         dictionary = {}
  29.         dictionary['question'] = questionstring
  30.         dictionary['answer']   = answerstring       
  31.  
  32.        self.qANDa.append(dictionary)
  33.  
  34.  
  35.     def outputdata(filename):
  36.         questionfilename = "files/"+filename +"_questions.tex"
  37.         answerfilename   = "files/"+filename +"_answers.tex"
  38.  
  39.         questionFile  = open(questionfilename, "w")
  40.         answerFile    = open(answerfilename, "w")        
  41.  
  42.         for ques in self.questions:
  43.             questionFile.write(ques+"\n")
  44.             questionFile.write("\\vspace{"+self.vspace+"}")
  45.  
  46.         for answ in self.answers:
  47.             answerFile.write(answ)        
  48.  
  49.         questionFile.close();
  50.         answerFile.close();
  51.  
Jan 12 '11 #1
1 4302
bvdet
2,851 Expert Mod 2GB
Your indentation is not consistent. My preference is to use 4 spaces.

Also - you don't need the trailing semi-colons at the end.
Jan 12 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Erik-Jan Bakker | last post by:
Hello, I am stuck with a weird javascript problem.... ;-( Maybe it's somehting very simple, but I am really stuck in it, right now. What's the matter.... When place my website at a different...
7
by: Craig | last post by:
When trying to create a new project on a new install of .NET 2003 I get the following error Error says Web server in not running asp.net 1.1 But I look in the administrative tools and it says...
3
by: Adam Short | last post by:
Can anyone help? I have all of a sudden started to receive this error on my site! I have no idea what script it is executing, why it is now failing, what is going on?? All I have been able...
11
by: westplastic | last post by:
This one is driving me insane. The script works perfect on Firefox, but Internet Explorer keeps complaining about "Error Object Expected" and stuff like that. I've run it through Firefox's Java...
1
ashsa
by: ashsa | last post by:
Hi all, I am getting an error in my page saying that A Runtime Error has occured. Do you wish to debug ? Line : 509 Error : Object Expected Could the Line number indicated be of any use...
7
by: juliejam | last post by:
Hello all, I am new here and hope some kind, smarter than me person can help. I am getting the error object expected with the following code: function click(e); here the error says it...
1
by: pratimapaudel | last post by:
function Showdiv() { var SelectStates = document.getElementById('Select1').value; if(SelectStates ="3") { document.getElementById("div2").style.display = "block"; } else ...
9
by: Rohit | last post by:
I am trying to initialize an array whose initializers depend on value of Enums. I take enum and then decide the initializer value, so that even if enum value changes because of addition to list...
3
by: cwggenius | last post by:
Getting the following error. But I cannot figure out why. Could someone please alter my code and explain where I am going wrong? ./checkprocess2.py File "./checkprocess2.py", line 19 ...
2
by: Bryan Vargas | last post by:
I keep getting the same "expected indented block" when ever I run my code. from myro import* init("simulator") def main(): for x in range(10): #repeats code in loop 10 times
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.