Answers for "for i python"

74

python loops

#x starts at 1 and goes up to 80 @ intervals of 2
for x in range(1, 80, 2):
  print(x)
Posted by: Guest on January-19-2020
3

python for loop

for i in range(5):
	print(i) #0, 1, 2, 3, 4
for i in range(2, 8):
  	print(i) #2, 3, 4, 5, 6, 7, 8
for i in range(2, 10, 2):
  	print(i) #2, 4, 6, 8, 10
for i in (['a', 'b', 'c']):
  print(i) #a, b, c
Posted by: Guest on December-29-2020
2

python for loop

for i in range(range_start, range_end):
  #do stuff here
  print(1)
Posted by: Guest on January-22-2021
1

python for loop

# Python for loop

for i in range(1, 101):
  # i is automatically equals to 0 if has no mention before
  # range(1, 101) is making the loop 100 times (range(1, 151) will make it to loop 150 times)
  print(i) # prints the number of i (equals to the loop number)
  
for x in [1, 2, 3, 4, 5]:
  # it will loop the length of the list (in that case 5 times)
  print(x) # prints the item in the index of the list that the loop is currently on
Posted by: Guest on January-09-2021
11

for in python

# how to use for in python for (range, lists)
fruits = ["pineapple","apple", "banana", "cherry"]
for x in fruits:
  if x == "apple":
    continue
  if x == "banana":
    break
  print(x)
# fron 2 to 30 by 3 step
for x in range(2, 30, 3):
  print(x)
Posted by: Guest on March-26-2020
0

for pyton

for i in range(n):
	#instruction
# other instruction out of the loop
Posted by: Guest on November-08-2020

Python Answers by Framework

Browse Popular Code Answers by Language