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
#to print number from 1 to 10
for i in range(1,11):
print(i)
#to print a list
l = [1,2,3,4]
for i in l:
print(i)
r = ["a","b","c","d","e"]
s = [1,2,3,4,5]
#print two list with the help of zip function
for p,q in zip(r,s):
print(p,q)
python for loop
a = 10
for i in range(1, 10) # the code will move from the range from 1 to 10 but not including 10
print(i)
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
python loop
# Python program to illustrate
# while loop
count = 0
while (count < 3):
count = count + 1
print("Hello Geek")
python for loops
# For loops are usually used to either loop through a list of somethings, or
# repeat a section of code a number of times.
# EXAMPLE - looping through a section of code 5 times #
for i in range(5):
print('Hello World!')
# NOTE: The 'i' variable counts how many times the code has ran, until it has
# reached 5
# EXAMPLE - printing each item in a list #
even_list = [2, 4, 6, 8, 10, 12]
for x in even_list:
print(x)
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