473,320 Members | 1,950 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,320 software developers and data experts.

How to fix: "expected indented block" error

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 11883
bvdet
2,851 Expert Mod 2GB
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 IndentationError 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
985 Expert 512MB
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
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 "" ...
4
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...
15
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...
32
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...
1
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): ...
7
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...
4
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
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...
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 ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.