itertools मॉड्यूल में Usin count() फ़ंक्शन समान रूप से दूरी वाले मानों का एक पुनरावर्तक देता है। फ़ंक्शन दो पैरामीटर लेता है। प्रारंभ डिफ़ॉल्ट रूप से 0 है और चरण डिफ़ॉल्ट रूप से 1 है। डिफ़ॉल्ट का उपयोग करने से अनंत पुनरावर्तक उत्पन्न होगा। लूप को समाप्त करने के लिए ब्रेक का उपयोग करें।
import itertools
percentNumbers = [ ]
finish = "n"
num = "0"
for x in itertools.count() :
num = input("enter the mark : ")
num = float(num)
percentNumbers.append(num)
finish = input("stop? (y/n) ")
if finish=='y':break
print(percentNumbers) उपरोक्त स्क्रिप्ट का नमूना आउटपुट
enter the mark : 11 stop? (y/n) enter the mark : 22 stop? (y/n) enter the mark : 33 stop? (y/n) y [11.0, 22.0, 33.0]