Answers for "run a for loop in python"

73

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

# Python for Loops

# There are 2 types of for loops, list and range.

# List:

food = ['chicken', 'banana', 'pie']
for meal in food: # Structure: for <temporary variable name> in <list name>:
  print(meal)
  # Will use the temporary variable 'meal' every time it finds an item in the list, and print it
  # So output is: chicken\nbanana\npie\n
# Range:
for number in range(9): # Will loop 9 times and temporaray variable number will start at 0 and end at 8
  print(number) # Prints variable 'number'
Posted by: Guest on October-03-2020
0

python for loop

for i in range(5):
  print(i)
# Output:
# 0
# 1
# 2
# 3
# 4
my_list = ["a", 1, True, 4.0, (0, 0)]
for i in my_list:
  print(i)
# Output:
# a
# 1
# True
# 4.0
# (0, 0)
Posted by: Guest on January-30-2021
0

run a for loop in python

for x in range(6):
  print(x)
Posted by: Guest on August-12-2021
1

how to do a for loop python

print(range(4))
>>> [0,1,2,3]
print(range(1,4))
>>> [1,2,3]
print(range(2,10,2))
>>> [2,4,6,8]
Posted by: Guest on June-15-2020

Code answers related to "run a for loop in python"

Python Answers by Framework

Browse Popular Code Answers by Language