Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security NachrichtenGoogle bestätigt: Gemini hackte drei Firmen bei KI-Security-Tests(20.09.2026 um 14:22 Uhr)
IT Security NachrichtenLMU München: Hacker-Angriff auf Immatrikulations-Daten(20.09.2026 um 13:37 Uhr)
IT Security NachrichtenJungfern-Flug: Flugzeug überquert erstmals autonom die gesamten USA(20.09.2026 um 13:41 Uhr)
IT NachrichtenA great new video game movie(20.09.2026 um 14:00 Uhr)
IT NachrichtenThe hidden monopoly behind your TI graphing calculator(20.09.2026 um 14:00 Uhr)
IT NachrichtenAll roads lead to cable(20.09.2026 um 14:00 Uhr)
IT Security NachrichtenGoogle bestätigt: Gemini hackte drei Firmen bei KI-Security-Tests(20.09.2026 um 14:22 Uhr)
IT Security NachrichtenLMU München: Hacker-Angriff auf Immatrikulations-Daten(20.09.2026 um 13:37 Uhr)
IT Security NachrichtenJungfern-Flug: Flugzeug überquert erstmals autonom die gesamten USA(20.09.2026 um 13:41 Uhr)
IT NachrichtenA great new video game movie(20.09.2026 um 14:00 Uhr)
IT NachrichtenThe hidden monopoly behind your TI graphing calculator(20.09.2026 um 14:00 Uhr)
IT NachrichtenAll roads lead to cable(20.09.2026 um 14:00 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

itertools in Python (11)

Reagiere als Erste:r — dein Feedback zählt!

Buy Me a Coffee

*Memo:

combinations() can return the iterator which uniquely combines the elements of iterable one by one to return a tuple of zero or more elements one by one as shown below:

*Memo:

  • The 1st argument is iterable(Required-Type:Iterable).
  • The 2nd argument is r(Required-Type:int):
    • It's the length of the returned tuple.
    • It must be 0 <= x.
from itertools import combinations

v = combinations(iterable='', r=0)
v = combinations(iterable=[], r=0)

print(v)
# <itertools.combinations object at 0x0000026906D95CB0>

print(next(v)) # ()
print(next(v)) # StopIteration:
from itertools import combinations

v = combinations(iterable='ABCD', r=1)
v = combinations(iterable=['A', 'B', 'C', 'D'], r=1)

print(next(v)) # ('A',)
print(next(v)) # ('B',)
print(next(v)) # ('C',)
print(next(v)) # ('D',)
print(next(v)) # StopIteration:
from itertools import combinations

for x in combinations(iterable='ABCD', r=2):
# for x in combinations(iterable=['A', 'B', 'C', 'D'], r=2):
    print(x)
# ('A', 'B')
# ('A', 'C')
# ('A', 'D')
# ('B', 'C')
# ('B', 'D')
# ('C', 'D')
from itertools import combinations

for x in combinations(iterable='ABCD', r=3):
# for x in combinations(iterable=['A', 'B', 'C', 'D'], r=3):
    print(x)
# ('A', 'B', 'C')
# ('A', 'B', 'D')
# ('A', 'C', 'D')
# ('B', 'C', 'D')
from itertools import combinations

for x in combinations(iterable='ABCD', r=4):
# for x in combinations(iterable=['A', 'B', 'C', 'D'], r=4):
    print(x)
# ('A', 'B', 'C', 'D')
from itertools import combinations

for x in combinations(iterable='ABCD', r=5):
# for x in combinations(iterable=['A', 'B', 'C', 'D'], r=5):
    print(x)
# Nothing

combinations_with_replacement() can return the iterator which non-uniquely combines the elements of iterable one by one to return a tuple of zero or more elements one by one as shown below:

*Memo:

  • The 1st argument is iterable(Required-Type:Iterable).
  • The 2nd argument is r(Required-Type:int):
    • It's the length of the returned tuple.
    • It must be 0 <= x.
from itertools import combinations_with_replacement

v = combinations_with_replacement(iterable='', r=0)
v = combinations_with_replacement(iterable=[], r=0)

print(v)
# <itertools.combinations_with_replacement object at 0x0000026906DAAED0>

print(next(v)) # ()
print(next(v)) # StopIteration:
from itertools import combinations_with_replacement

v = combinations_with_replacement(iterable='ABCD', r=1)
v = combinations_with_replacement(iterable=['A', 'B', 'C', 'D'], r=1)

print(next(v)) # ('A',)
print(next(v)) # ('B',)
print(next(v)) # ('C',)
print(next(v)) # ('D',)
print(next(v)) # StopIteration:
from itertools import combinations_with_replacement

for x in combinations_with_replacement(iterable='ABCD', r=2):
# for x in combinations_with_replacement(iterable=['A', 'B', 'C', 'D'], r=2):
    print(x)
# ('A', 'A')
# ('A', 'B')
# ('A', 'C')
# ('A', 'D')
# ('B', 'B')
# ('B', 'C')
# ('B', 'D')
# ('C', 'C')
# ('C', 'D')
# ('D', 'D')
from itertools import combinations_with_replacement

for x in combinations_with_replacement(iterable='ABCD', r=3):
# for x in combinations_with_replacement(iterable=['A', 'B', 'C', 'D'], r=3):
    print(x)
# ('A', 'A', 'A')
# ('A', 'A', 'B')
# ('A', 'A', 'C')
# ('A', 'A', 'D')
# ('A', 'B', 'B')
# ('A', 'B', 'C')
# ('A', 'B', 'D')
# ('A', 'C', 'C')
# ('A', 'C', 'D')
# ('A', 'D', 'D')
# ('B', 'B', 'B')
# ('B', 'B', 'C')
# ('B', 'B', 'D')
# ('B', 'C', 'C')
# ('B', 'C', 'D')
# ('B', 'D', 'D')
# ('C', 'C', 'C')
# ('C', 'C', 'D')
# ('C', 'D', 'D')
# ('D', 'D', 'D')
from itertools import combinations_with_replacement

for x in combinations_with_replacement(iterable='ABCD', r=4):
# for x in combinations_with_replacement(iterable=['A', 'B', 'C', 'D'], r=4):
    print(x)
# ('A', 'A', 'A', 'A')
# ('A', 'A', 'A', 'B')
# ('A', 'A', 'A', 'C')
# ('A', 'A', 'A', 'D')
# ('A', 'A', 'B', 'B')
# ('A', 'A', 'B', 'C')
# ('A', 'A', 'B', 'D')
# ('A', 'A', 'C', 'C')
# ('A', 'A', 'C', 'D')
# ('A', 'A', 'D', 'D')
# ('A', 'B', 'B', 'B')
# ('A', 'B', 'B', 'C')
# ('A', 'B', 'B', 'D')
# ('A', 'B', 'C', 'C')
# ('A', 'B', 'C', 'D')
# ('A', 'B', 'D', 'D')
# ('A', 'C', 'C', 'C')
# ('A', 'C', 'C', 'D')
# ('A', 'C', 'D', 'D')
# ('A', 'D', 'D', 'D')
# ('B', 'B', 'B', 'B')
# ('B', 'B', 'B', 'C')
# ('B', 'B', 'B', 'D')
# ('B', 'B', 'C', 'C')
# ('B', 'B', 'C', 'D')
# ('B', 'B', 'D', 'D')
# ('B', 'C', 'C', 'C')
# ('B', 'C', 'C', 'D')
# ('B', 'C', 'D', 'D')
# ('B', 'D', 'D', 'D')
# ('C', 'C', 'C', 'C')
# ('C', 'C', 'C', 'D')
# ('C', 'C', 'D', 'D')
# ('C', 'D', 'D', 'D')
# ('D', 'D', 'D', 'D')
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten itertools in Python (11)

Thematisch verwandte Begriffe: itertools, Python · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-93956 | A flaw has been found in olivier-ls PHP-FTS up to 1.1.2. Affected by thi…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick