🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)

🔧 Programmierung 🕛 kürzlich 3 Min Lesezeit
0

Day 6 - For loop & If condition

↗ Quelle (dev.to)
🗣️ Stimme:

for loop:



A for loop in Python is used to iterate over a sequence and perform a block of code for each element in that sequence.



Stntax:




CODE
for variable in sequence:






Example:




CODE
txt = '1234'

for num in txt:
print(num,end=' ')






Output:




CODE
1 2 3 4






if condition:



The if condition is a fundamental control structure in programming, used to make decisions based on whether a given condition is true or false.



Syntax:




CODE
if condition:
# Code block to execute if condition is True
else:
# Code block to execute if condition is False (optional)







Example:




CODE
x = 10
if x > 5:
print("x is greater than 5")
else:
print("x is 5 or less")







Output:




CODE
x is greater than 5






Example for forloop and if condition:




CODE
txt = '12a4'

for num in txt:
if num>='0' and num<='9':
print(num,end=' ')
else:
print('Not Decimal',end=' ')






Output:




CODE
1 2 Not Decimal 4






The code checks each character in the string txt to determine if it represents a digit. If the character is between '0' and '9', it is printed; otherwise, it prints 'Not Decimal'




CODE
name = input("Your Name please: ")
print(name)
for alphabet in name:
print(alphabet, end='*')










CODE
Your Name please: pritha
pritha
p*r*i*t*h*a*






Excercise:




CODE
name1 = input("Enter the first name: ")
name2 = input("Enter the second name: ")
name3 = input("Enter the third name: ")
name4 = input("Enter the fourth name: ")
name = [name1, name2, name3, name4]

# Check if names start with 'G'
for letter in name:
if letter[0] == 'G':
print(letter)

# Check if names end with 'a'
for alphabet in name:
if alphabet[-1] == 'a':
print(alphabet)

# Check if names contain a space
for alpha in name:
for i in alpha:
if i == ' ':
print(alpha)
break
# Check if names are longer than 9 characters
for character in name:
if len(character) > 9:
print(character)






1.if letter[0] == 'G': checks if the first character of the name is 'G'.

2.if alphabet[-1] == 'a': checks if the last character of the name is 'a'.

3.if i == ' ': prints the name if a space is found, then exits the inner loop with break.

4.if len(character) > 9: checks if the length of the name exceeds 9.




CODE
Enter the first name:Lakshmi Pritha
Enter the second name:Guru Prasanna
Enter the third name:Guhanraja
Enter the fourth name:Varatharajan
Guru Prasanna
Guhanraja
Lakshmi Pritha
Guru Prasanna
Guhanraja
Lakshmi Pritha
Guru Prasanna
Lakshmi Pritha
Guru Prasanna
Varatharajan












Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
3 Quellen
GPT-6 Astra Release Today? OpenAI’s Next Major AI Model Is Almost Here
1 Quelle
Apple accuses OpenAI of destroying evidence as trade-secrets fight intensifies
1 Quelle
Major AI platforms go down in unprecedented simultaneous outage
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Day 6 - For loop & If condition

Thematisch verwandte Begriffe: loop, condition · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...