so im writing this program. i wont bother with posting the whole thing, cause its like 200 lines and ive barely started. (huge potensial for error, the way i like it)
anyways, in the part ive completed of my program, theres a very large chance that the program will not be able to execute. so i put this bugger on top of it:
for x in range(1,100):
when i run my program, it works like 3 or 4 times. the problem is, it then prints all the individual answers it got 3 or 4 times. so my question is, how do i make it print only the first answer it gets?
any help is apprechiated. :)
2 1843
so im writing this program. i wont bother with posting the whole thing, cause its like 200 lines and ive barely started. (huge potensial for error, the way i like it)
anyways, in the part ive completed of my program, theres a very large chance that the program will not be able to execute. so i put this bugger on top of it:
for x in range(1,100):
when i run my program, it works like 3 or 4 times. the problem is, it then prints all the individual answers it got 3 or 4 times. so my question is, how do i make it print only the first answer it gets?
any help is apprechiated. :)
I don't really understand what you are trying to do. Are you trying to break out of the for loop when something happens: -
for x in range(1, 100):
-
# something happens
-
break #breaks out of the loop
-
so im writing this program. i wont bother with posting the whole thing, cause its like 200 lines and ive barely started. (huge potensial for error, the way i like it)
anyways, in the part ive completed of my program, theres a very large chance that the program will not be able to execute. so i put this bugger on top of it:
for x in range(1,100):
when i run my program, it works like 3 or 4 times. the problem is, it then prints all the individual answers it got 3 or 4 times. so my question is, how do i make it print only the first answer it gets?
any help is apprechiated. :)
I don't quite follow you, but it could just be a matter of indentation: -
>>> for i in range(5):
-
... print 'testing in loop %d' %i
-
... print 'test value = %d' %(i**2)
-
...
testing in loop 0
test value = 0
testing in loop 1
test value = 1
testing in loop 2
test value = 4
testing in loop 3
test value = 9
testing in loop 4
test value = 16 -
>>> for i in range(5):
-
... print 'testing in loop %d' %i
-
...
-
# by de-indenting here only the last value shows up
-
>>> print 'test value = %d' %(i**2)
testing in loop 0
testing in loop 1
testing in loop 2
testing in loop 3
testing in loop 4
test value = 16
>>>
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Orin Hargraves |
last post by:
I'm formatting data in a text file using a "For Each aPara" statement
along with a "Next aPara." How do I make the thing stop when it
reaches the end of the file, rather than starting again at the...
|
by: Daniel Haude |
last post by:
Hi guys,
I'm using a height="100%" attribute in a <table> tag to get the
obvious effect (a table which fills the entire available
space). html-tidy, however, complains that this is proprietary,...
|
by: Frederick Gotham |
last post by:
Is the domestic usage of the C "for" loop inefficient when it comes to
simple incrementation? Here's a very simple program that prints out the
bit-numbers in a byte.
#include <stdio.h>
#include...
|
by: Tantale |
last post by:
I used this serviec to check my webpage
http://www.jmrw.com/Abroad/Barcelone/index.htm Made with Dreamweaver 8.
The result is 206 errors, most of them "end tag omitted, but OMITTAG NO was...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
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...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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...
|
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...
| | |