473,386 Members | 2,114 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.

Limiting output for loop

1
Hi.

I'm trying to limit the output of a for loop to 200 counts and then breaking it. The purpose of the loop is to print out defined unicode characters onto a html table after a user sets the range.

So far I have this:

Expand|Select|Wrap|Line Numbers
  1. start = form["start"].value
  2. end = form["end"].value
  3. .
  4. .
  5. for char in range(int(start),int(end)+1):
  6.     name = unicodedata.name(unichr(char), "undefined" )
  7.     if name != "undefined":
  8.         print "<tr><td class=\"num\">" + str(char) + "</td><td><code class=\"html\">&amp;#" + str(char) + ";</code>""</td><td class=\"char\"><span>&#" + str(char) + ";</span></td><td class=\"name\">" + name + "</td></tr>"
I've tried using this within the loop:
Expand|Select|Wrap|Line Numbers
  1. for count, char in enumerate(range(int(start),int(end)+1)):
  2.   if count >= 200:
  3.       break
But nothing seems to work.

Thank you in advance for any help.
Nov 14 '08 #1
2 1356
Curtis Rutland
3,256 Expert 2GB
Please enclose your posted code in [CODE] [/CODE] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [CODE] [/CODE] tags in future.

MODERATOR
Nov 14 '08 #2
bvdet
2,851 Expert Mod 2GB
I think you were on the right track. You were trying to do something like this:
Expand|Select|Wrap|Line Numbers
  1. >>> for i, count in enumerate(range(100,120)):
  2. ...     if i > 10:
  3. ...         break
  4. ...     print count
  5. ...     
  6. 100
  7. 101
  8. 102
  9. 103
  10. 104
  11. 105
  12. 106
  13. 107
  14. 108
  15. 109
  16. 110
  17. >>> 
Nov 14 '08 #3

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

Similar topics

6
by: Kingdom | last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the results. Choose a component type from the first drop down, lets say 'car' and the second box will list all the car...
1
by: sks | last post by:
Hi, I have a products table which apart from other things has a column called manufacturer. I want to run a query that returns x number of products PER manufacturer for each manufacturer that...
2
by: nzanella | last post by:
Hello, I am running SQL Server 2000. I would like to know whether Microsoft Transact-SQL has a method for limiting the result set from a query in a way analogous to MySQL's LIMIT keyword, so...
54
by: bnp | last post by:
Hi, I took a test on C. there was an objective question for program output type. following is the program: main() { char ch; int i =2;
0
by: mfilpot | last post by:
I am working on a prime number generator for sschool, but I jsut can't seem to figure out how to write the contents of the variable MeSSage into a new text file, Can someone help me? the script...
3
by: undshan | last post by:
I am writing a code that needs to open a file, create an output file, run through my function, prints the results to the output file, and closes them within a loop. Here is my code: #include...
21
by: Umesh | last post by:
/*program to search a* in a text file & write output in a file.* indicated any character*/ #include<stdio.h> #include<stdlib.h> int main(void) { FILE *f,*fp; f=fopen("c:/1.txt","r");...
0
by: LanaR | last post by:
Hello, one sql statement is causing severe performance issue. The problem occurs only in UDB environment, the same statemnt on the mainframe is running fine. I have an explain output from the sql....
109
by: bonneylake | last post by:
Hey Everyone, Well i am having a problem outputting for my report and hoping someone can explain what i am doing wrong. What the report is about is comparing my company's part price's to d and...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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,...

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.