Answers for "for loop in pyth"

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

# 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: chickennbanananpien
# 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
2

python for loop

for number in range(10):
  print(number)
Posted by: Guest on November-04-2020
1

python for loop

fruits = ["apple", "banana", "cherry"]
for x in fruits:
    print(x)
Posted by: Guest on June-17-2021

Python Answers by Framework

Browse Popular Code Answers by Language