# File: for.py # show different ways to use range or lists in for loops # # Matt Bishop, MHI 289I, Fall 2024 # # # range with 1 number: generate numbers from 0 up to # but not including that number # print("This is for i in range(3):") for i in range(3): print(i) # # range with 2 numbers: generate numbers from the first up to # but not including the second # print("This is for i in range(-3,3):") for i in range(-3,3): print(i) # # range with 3 numbers, third one positive: generate numbers # from the first up to but not including the second, counting # with step of the third # print("This is for i in range(-3, 3, 2):") for i in range(-3, 3, 2): print(i) # # range with 3 numbers, third one negative: generate numbers # from the first one to but not including the second, counting # with step of the third # print("This is for i in range(3, -3, -2):") for i in range(3, -3, -2): print(i) # # range with 3 numbers, third one negative: generate numbers # from the first one to but not including the second, counting # with step of the third # print("This is for i in range(-3, 3, -2):") for i in range(-3, 3, -2): print(i)