python loops
#x starts at 1 and goes up to 80 @ intervals of 2
for x in range(1, 80, 2):
print(x)
python loops
#x starts at 1 and goes up to 80 @ intervals of 2
for x in range(1, 80, 2):
print(x)
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'
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)
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]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us