473,670 Members | 2,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to fix: "expected indented block" error

1 New Member
I keep getting the same "expected indented block" when ever I run my code.

Expand|Select|Wrap|Line Numbers
  1. from myro import*
  2.  
  3. init("simulator")
  4.  
  5. def main():
  6.  
  7. for x in range(10): #repeats code in loop 10 times
  8.  
  9. forward(1,1) # go forward for a small distance
  10.  
  11. backward(1,1) # go backwards the same distance as forward
  12.  
  13. turnLeft(50,30) # slight turn to vacuum a new area 
  14.  
  15. main()
Nov 1 '10 #1
2 11920
bvdet
2,851 Recognized Expert Moderator Specialist
You have no indentation in your code. Indentation is required to denote different blocks of code. The interpreter expects the indentation after certain statements and an IndentationErro r is raised if not present. Example:
Expand|Select|Wrap|Line Numbers
  1. >>> for i in range(10):
  2. ... print i
  3. Traceback (IndentationError: expected an indented block (<interactive input>, line 2)
  4. >>> 
Nov 1 '10 #2
Oralloy
988 Recognized Expert Contributor
You forgot to indent the statements wrapped in the "for" loop.

Expand|Select|Wrap|Line Numbers
  1. from myro import* 
  2. init("simulator") 
  3. def main(): 
  4. for x in range(10): #repeats code in loop 10 times 
  5.   forward(1,1) # go forward for a small distance 
  6.   backward(1,1) # go backwards the same distance as forward 
  7.   turnLeft(50,30) # slight turn to vacuum a new area  
  8. main() 
Nov 1 '10 #3

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

Similar topics

4
5225
by: Grzegorz Dostatni | last post by:
Good morning. I've got a Tkinter problem: File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 2310, in selection_present return self.tk.getboolean( TclError: expected boolean value but got "" Now a few weeks ago there was a similar problem with the boolean value. That's when the tcl started returning "???" for unknown fields in a
4
7735
by: Axel Dahmen | last post by:
Hi, current browsers don't support "display: inline-block;" and "display: inline-table;", resp. Thus I'm using "float: left;" to achieve a similar effect. Problem is that if a row of elements uses this kind of block floating, they don't wrap to build a whole new line but instead get "hooked" at the left-most element being larger than the element right beside this "overflowing" element.
15
2958
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting it. Simple database: I want to have a user enter Supply Orders (just for tracking purposes) by Item. The user may also enter a new item - "new" is a combination of Item, PartNumber and Vendor - they could have the
32
4129
by: James Curran | last post by:
I'd like to make the following proposal for a new feature for the C# language. I have no connection with the C# team at Microsoft. I'm posting it here to gather input to refine it, in an "open Source" manner, and in an attempt to build a ground-swell of support to convince the folks at Microsoft to add it. Proposal: "first:" "last:" sections in a "foreach" block The problem: The foreach statement allows iterating over all the...
1
2389
by: Adam Clauss | last post by:
I have a doc/view app w/ a CRichEditView. In it, I define: void CSyntaxView::ParseLine(long lineNum); This function starts off by getting the text of the specified line (into a CString): CRichEditCtrl* ctrl = &GetRichEditCtrl(); int lineLen = ctrl->LineLength(lineNum); char* buf = new char; ctrl->GetLine(lineNum, buf, lineLen);
7
92081
by: Warrax | last post by:
I am currently doing online tutorials for C++, and am pretty much stuck in a rut about this problem. It is saying that there's an expected unqualifed-id before '{' token (I will post the code in just a second) on line 11, and an expected ',' or ';' before '{' token also on line 11, however I don't have a clue what the first one means. The program is meant to save a user's name in a string variable within a structure, and to then show that name...
4
5796
by: Daniel | last post by:
is there some per-process-limit on memory in .net processes? is there any way to increase it? i keep getting System.OutOfMemoryException when my box has 8 gigs of unused memory.
1
3270
by: nagaraj | last post by:
In Dev C++, we tried to compile a application, but it will throw some peculiar error. please find it below "path/main.cpp expected `]' before ';' token" and the source code is "DWORD rtec_Stack __attribute__((aligned(4)));" is this problem of envirnment or else?
9
11183
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
0
8466
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
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
8901
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...
0
8813
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8591
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
7412
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...
1
6212
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
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();...
2
2037
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.