473,396 Members | 2,018 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,396 software developers and data experts.

Problems with range

Hey to everybody, im just beginning to program in python. So i was trying
some function but always when i try the range function i get a error
message.

for number in range(1,100):
print number

Error---> There's an error in your program:
expected an indented block

I tried many examples i found at different tutorials but i always get the
error.
Jul 18 '05 #1
4 2372
On Fri, 25 Jun 2004 19:06:39 -0400, Adrian Albisser <ju*******@123.cl> wrote:
Hey to everybody, im just beginning to program in python. So i was trying
some function but always when i try the range function i get a error
message.

for number in range(1,100):
print number

Error---> There's an error in your program:
expected an indented block


Read what the message tells you. The problem is not with your range
function, it's the rest of the program. In Python, indenting is
important; it tells the interpreter which bits go together.

So your program should be:
for number in range(1,100):
print number

Note the 4 spaces at the start of the second line. It doesn't have to be
4 spaces, but that's convention.

I'd suggest you read a good python tutorial - I like
http://www.freenetpages.co.uk/hp/ala...d/tutintro.htm

And of course there's http://www.python.org/doc/current/tut/ on the
python site itself.

chris
Jul 18 '05 #2
Hi all,

I'm writing an HTTP client test package in python to test my C++ proxy
server (http://www.summitsage.com/). For this reason I want to construct
the (malformed) HTTP requests myself, but use httplib to parse the
server's response. I don't see an easy way to do this. I suspect I could
construct the response on the socket and have it read the response, but
this is undocumented.

Any suggestions?

tia.

--
Christopher Baus
http://www.baus.net/
Tahoe, Wine, and Linux.

Jul 18 '05 #3
On Fri, 25 Jun 2004 19:06:39 -0400, Adrian Albisser wrote:
Hey to everybody, im just beginning to program in python. So i was trying
some function but always when i try the range function i get a error
message.

for number in range(1,100):
print number


Try:
for number in range(1,100):
print number
^^
Note the intention.

Basically, any time you have a line ending in :, you'll need to indent
the following line (and maybe more).

Jul 18 '05 #4
> I'm writing an HTTP client test package in python to test my C++ proxy
server (http://www.summitsage.com/). For this reason I want to construct
the (malformed) HTTP requests myself, but use httplib to parse the
server's response. I don't see an easy way to do this. I suspect I could
construct the response on the socket and have it read the response, but
this is undocumented.


To answer my own question. This isn't documented in the standard python
docs, but it is seems to work:

response = httplib.HTTPResponse(sock)
response.begin()
print response.read()
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Sean Cody | last post by:
I'm trying to take a webpage that has a nxn table of entries (bus times) and convert it to a 2D array (list of lists). Initially this was simple but I need to be able to access whole 'columns' of...
20
by: Lucas Raab | last post by:
I'm done porting the C code, but now when running the script I continually run into problems with lists. I tried appending and extending the lists, but with no avail. Any help is much appreciated...
11
by: Bob Hairgrove | last post by:
The following class contains start and end points of a range of values. The range can have a direction which is implied from the relative order of start and end, or it can be without direction. IOW...
55
by: drhowarddrfine | last post by:
I'm working on a web site that could use some control using js but am concerned about what problems I may have with potential users having their js turned off. Has anyone had any serious problems...
2
by: kosecki | last post by:
Hi, I can't find the way to do something from vb .net in current copy of Excel. All posts which I read tell how to make application.excel object and do something. I need to write something like...
1
by: defcon8 | last post by:
Hello. I have been trying to use PIL's .putdata() method and I have been having some problems. The error I get is: Traceback (most recent call last): File "realautomata.py", line 72, in ?...
1
by: Mario Lacunza | last post by:
--------- Mensaje reenviado -------- De: Mario Lacunza <mario.lacunza@gmail.com> Para: Lista Python Ing <python-list@python.org> Asunto: Problems with PyGridTableBase Fecha: Sat, 09 Sep 2006...
9
by: =?Utf-8?B?SG93YXJkIFNtaXRo?= | last post by:
I am using VC++ 6.0 (with SP5 installed). When using WinXP this is with SP2 installed. I am developing an instrumentation system comprising a set of networked PCs connected using TCP/IP TCP links....
0
by: Edwin.Madari | last post by:
use songs.extend( asongs ) #append is for single item - where ever it mightbe. good luck. Edwin -----Original Message-----
0
by: Julia1 | last post by:
Actually I have encountered several problems working with Word. Please see if you can help me resolve them. My application creates documents (Microsoft.Interop.Word.Document) each one according...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.