+ 4
How to make infinite loop by using FOR LOOP ? Solved.
I can do it by WHILE LOOP only.
21 ответ
+ 12
You can not directly do it with a for loop, because a for loop always loops over an iterable.
The iterable, however, can be built in a way that it dishes out values forever.
(EDIT: Diegos example shows one example of that sort of iterable.)
Please look at this question from a month ago which is basically what you're asking for.
https://www.sololearn.com/discuss/2132309/?ref=app
+ 11
import itertools
for i in itertools.count():
print(i)
break # Remove this to create an infinite loop
+ 11
Hello @Jacob
A friendly reminder that the behavior you've exhibited on this thread thus far is inappropriate.
To cite our Community Guidelines:
"SoloLearn's policies are based on two key principles:
- Posts by SoloLearn community members should be programming-related and aimed at helping individual learners and community members improve their programming skills by creating a respectful resource base. Posts may also focus on improving aspects of the platform and providing the community with improved content, whenever applicable.
- Personal attacks or disparagement of other users or their content is not tolerated. Every community member should be respectful and considerate, and assume that other people are also trying to make SoloLearn a great development resource. This means respecting opposing or differing opinions, beliefs, and conclusions; making an effort to listen to and understand others with whom you may disagree; and encouraging others to also be welcoming and respectful."
https://www.sololearn.com/Content-Creation-Guidelines/
Please note the number of occurrences of the word "respectful" in the above excerpt.
I found the following replies to be noncompliant:
- "i dont care what u think,"
- "~ swim ~ yea, STOP POSTING ABOUT UNRELATED TOPICS PLEASE AND THANK YOU"
- "~ swim ~ i didnt know about caps lock, but i do know i wont get banned for this"
Please remove your posts in a timely fashion or I will remove them for you.
If you continue to behave in a noncompliant manner, moderators do have the power to ban you -- contrary to what you've expressed. Please take heed.
Warmest regards,
-- Janning
SoloLearn Gold Moderator
+ 9
Hello Everyone,
As ~ swim ~ said:
"Please learn to curb the urge to post unnecessarily. Read the question properly before posting."
Irrelevant posts substantially lower the quality of information available in our forum. Therefore, as a moderator, I can clean up this thread by removing any replies I determine to be off-topic.
If you have any doubts about this, please review our Community Guidelines at:
https://www.sololearn.com/Content-Creation-Guidelines/
As it states:
"If your content/post is not specifically on-topic, it can be deleted."
In the meantime, please consider providing helpful/useful insights in thread(s) which may actually be relevant to what you wanted to share. You can practice using the search feature to find such threads.
Happy coding!
Best,
-- Janning⭐
SoloLearn Gold Moderator
+ 4
Ok I got it
+ 4
def lettersforever():
n = 0
while True:
yield chr(n+97)
n = (n+1)%26
for letter in lettersforever():
print(letter)
+ 4
Same goes for 😈😈😈😈😈😈😈:
This is about for loops, which have no conditions.
Please read questions properly, and ideally also the formerly given answers!
+ 4
It is not possible to make an infinite loop with for loop because it will iterates based on the number of elements in the sequence.
Syntax for For loop:
for variable in sequence
Infinite loop is possible with while loop.
+ 4
Thanks for everyone but really I not need any more answer.
+ 3
Thanks
+ 3
Cp Chaudhary, you can edit your question and write [solved] in front of the title.
It might help... somewhat. 🙄
Also you can click the star in the lower left of your question, then you won't get any more notifications.
+ 3
for( i=0; true; i++) { ... }
+ 2
Jacob Burgess, 'I don't know python'.
So why not stop right there?
What do you hope to achieve adding information that has no relation to the question?
+ 1
X = [4,5,6,7]
For i in x:
counter =+ 1
print(x)
+ 1
Infinite loop
for(; ;)
{
}
+ 1
for(I=1;I;I++) ;
Here is infinite foor loop
+ 1
Its very simple with c try out this
https://code.sololearn.com/cJU8wnszxYSW/?ref=app
0
Miss the condition inside and iterate it using increment operator,you will get infinite loop.
0
for(;;)