Advertisement
Cobble5tone

Educational use of range

Aug 24th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. condition = (1, 16) # This is just a tupple. I think you're tyring to print a range
  2. while condition != 0:  # This logic would be nonsensical to the computer as you're basically saying as long as condition
  3.     # does not equal zero, then keep printing
  4.     print(condition)
  5.  
  6.  
  7.  
  8. for i in range(1, 16):  #  This is what I think you're trying to achieve
  9.     print(i)  # This prints every number from 1 to 16, but will end up with an output at 15
  10.  
  11.  
  12. #  Below is an alternative way
  13. number = 1  # We initialize number as 1 because  that's where we want to start
  14.  
  15. while number != 16:  # We set the condition that, while number doesn't equal 16, then keep printing
  16.     print(number)
  17.     number += 1  # We add one to number to keep moving the number up one
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement