May-03-2020, 02:09 AM
windows 10, python 3.8
Trying to do zigzag example but not getting right result. I type following code, which I think is identical to the lesson's:
But instead of getting a looping result like this:
...I am instead getting a looping result like this:
Trying to do zigzag example but not getting right result. I type following code, which I think is identical to the lesson's:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import time, sys indent = 0 # How many spaces to indent. indentIncreasing = True #Whether the indentation is increasing or not. try : while True : #The main program loop print (' ' * indent, end=' ') print ( '********' ) time.sleep( 0.1 ) #Pause for 1/10 of a second. if indentIncreasing: #Increase the number of spaces: indent = indent + 1 if indent = = 20 : #Change direction: indentIncreasing = False else : #Decrease the number of spaces: indent = indent - 1 if indent = = 0 : #Change direction: indentIncreasing = True except KeyboardInterrupt: sys.exit() |
1 2 3 4 5 6 7 8 9 |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
1 2 3 4 5 6 7 8 9 |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |