Answers for "for looping in 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

how to use for loops python

#simple for loop to print numbers 1-99 inclusive
for i in range(1,100):
  print(i)
  
#simple for loop to loop through a list
fruits = ["apple","peach","banana"]
for fruit in fruits:
  print(fruit)
Posted by: Guest on October-25-2020
2

python for loop

# Range:
for x in range(5):
  print(x) # prints 0,1,2,3,4

# Lists:
letters = ['a', 'b', 'c']
for letter in letters:
  print(letter) # prints a, b, c
  
# Dictionaries:
letters = {'a': 1, 'b': 2, 'c': 3}
for letter, num in letters.items():
  print(letter, num) # prints a 1, b 2, c 3
Posted by: Guest on October-04-2020
1

python for loop

for _ in range(10):
  print("hello")
# Print "hello" 10 times
Posted by: Guest on February-08-2021
0

python for loop

n = int(input("All numbers in given range"))
for i in range(n):
  print(i)
Posted by: Guest on April-09-2021

Python Answers by Framework

Browse Popular Code Answers by Language