Pythone pro smyčku

Příklady kódu

69
0

python smyčky

#x starts at 1 and goes up to 80 @ intervals of 2
for x in range(1, 80, 2):
  print(x)
1
0

smyčka v Pythonu

# A Sample Python program to show loop (unlike many 
# other languages, it doesn't use ++) 
# this is for increment operator here start = 1,  
# stop = 5 and step = 1(by default) 
print("INCREMENTED FOR LOOP") 
for i in range(0, 5): 
   print(i) 
  
# this is for increment operator here start = 5,  
# stop = -1 and step = -1  
print("\n DECREMENTED FOR LOOP") 
for i in range(4, -1, -1): 
   print(i) 
1
0

python pro smyčku

for x in range(10):
	print(x)
// output: 1,2,3,...,10
    
for x in range(10, 20, 2):
	print(x)
// output: 10, 12, 14, 16, 18, 20

list = [2, 3, "el"]
for x in list:
	print(x)
// output: 2, 3, "el"

for _ in range(10):
  print("a");
// Do the loop without using index

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................