Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. def loops(value_1,value_2,step,iterable):  
  2.     if (value_1 > value_2 and step > 0):
  3.         print("Output for 'for' loop: ")
  4.         for i in range(value_2,value_1 + 1,step):
  5.             print(i, end=" ")  
  6.     elif value_1 > value_2 and step < 0:
  7.         print("Output for 'for' loop: ")
  8.         for i in range(value_1, value_2 - 1, step):    
  9.             print(i, end=" ")
  10.      
  11.  
  12.     if value_1 < value_2 and step > 0:
  13.         for i in range(value_1, value_2 + 1, step):
  14.             print(i, end=" ")
  15.     elif value_1 < value_2 and step < 0:
  16.         for i in range(value_2, value_1 +1, step):
  17.             print(i, end= " ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement