Answers for "for loop python iterate by 2"

17

python loop two

for f, b in zip(foo, bar):
    print(f, b)
Posted by: Guest on March-30-2020
2

python for loop 2 items at a time

# ------------- For loop using 2 items of a list --------------- #

# This code is trying to find if a point belongs between
# the interval of pairing points of a list:

mylist = [117, 202, 287, 372, 457, 542]
point = 490
# 117 < x < 202  ? 
# 287 < x < 372  ?
# 457 < x < 542  ?

for i, j in zip(mylist[::2], mylist[1::2]):
  if i < point < j:
    print ("This point exists between: ", i, " - ", j)
    break
Posted by: Guest on August-28-2020
2

Range python iterate by 2

for i in range(0,10,2):
  print(i)
Posted by: Guest on May-20-2020

Code answers related to "for loop python iterate by 2"

Python Answers by Framework

Browse Popular Code Answers by Language