“Python -Iteration” Code-Antworten

Iteration mit für Schleifen in Python

names = ["Preet", "Ranjeet", "Adil"]
for name in names:
    print(name)
Outrageous Ostrich

Python -Iteration

# a 'while' loop runs until the condition is broken
a = "apple"
while a == "apple":
  a = "banana" # breaks loop as 'a' no longer equals 'apple'
  
# a 'for' loop runs for the given number of iterations...
for i in range(10):
  print(i) # will print 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

# ... or through a sequence
array = [3, 6, 8, 2, 1]
for number in array:
  print(number) # will print 3, 6, 8, 2, 1
panda

Python wiederholen

for n in range(3):   
print(n)
Rich Raccoon

Wie man Iteration in Python verwendet


n = 5
while n > 0:
    print n
    n = n-1
print 'Blastoff!'
Worrisome Willet

Ähnliche Antworten wie “Python -Iteration”

Fragen ähnlich wie “Python -Iteration”

Weitere verwandte Antworten zu “Python -Iteration” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen