Jak smyčka funkce v Pythonu

Příklady kódu

34
0

pro smyčku python

Python Loops

for x in range(1, 80, 2):
  print(x)

words=['zero','one','two']
for operator, word in enumerate(words):
	print(word, operator)

for x in range(1, 80, 2):
  print(x)




12
0

pro v Pythonu

for i in range(1,10,2): #(initial,final but not included,gap)
  print(i); 
  #output: 1,3,5,7,9
  
for i in range (1,4): # (initial, final but not included)
  print(i);
  #output: 1,2,3 note: 4 not included

for i in range (5):
  print (i);
  #output: 0,1,2,3,4 note: 5 not included

python = ["ml","ai","dl"];  
for i in python:
  print(i);
  #output:  ml,ai,dl
  
for i in range(1,5):	#empty loop...if pass not used then it will return error
  pass; 	
  
9
0

pytho smyčky

for x in loop:
	print(x)
3
0

python pro smyčku

A for loop iterates through an iterable, may that be an array, a string, or a range of numbers
#Example:
myArr = ["string 1", "string 2"]
for x in myArr:
  print(x)
#Returns "string 1", "string 2". In here the x is an iterator and does not need to be defined.
2
0

python pro smyčku

a = 10 
for i in range(1, 10) # the code will move from the range from 1 to 10 but not including 10
	print(i)

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
..................................................................................................................