473,671 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

There is an indentation error that says expected an indented block

1 New Member
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
^
IndentationErro r: 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 4321
bvdet
2,851 Recognized Expert Moderator Specialist
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
44528
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 hosting provider my webpage menu generates the javascript error:
7
1478
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 Microsoft .NET Framework 1.1 Configuration How can I fix this?
3
4667
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 to find out is that Microsoft has had the same problem on their site!
11
44232
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 Console, and it comes back with no errors. Any pointers on this, would be much appreciated. <script type="text/javascript"> <!-- var p = new Array(0,0,0,0,0) var c = new Array(0,0,0,0,0,0,0,0,0)
1
1658
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 in locating the error ? It opens the microsoft script debugger by default when i select yes. But no indication of where the error is . It simply shows an yellow arrow on the line <Body>. Is there any other debugger available that shows the exact...
7
2293
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 expected '{' at Char:18 External js code for this is here: function click(e) { if (document.all) {
1
3065
by: pratimapaudel | last post by:
function Showdiv() { var SelectStates = document.getElementById('Select1').value; if(SelectStates ="3") { document.getElementById("div2").style.display = "block"; } else document.getElementById("div2").style.display = "none";
9
11184
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 even then I should be able to get correct value for the array element. I need value and state to be present in a single byte thats why I use macros. Here is what my code look like: typedef enum
3
4477
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 else: ^ IndentationError: expected an indented block #!/usr/bin/python
2
11921
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
8400
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8602
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7441
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4412
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.