File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change 7
7
pyramid_character = raw_input ("Enter some text: " )
8
8
pyramid_size = int (raw_input ("And the size of your side word pyramid: " ))
9
9
10
+
10
11
def create_pyramid (character , size ):
11
12
""" Prints a sideword pyramid """
12
- loop_counter = 1
13
- increment = 1
14
- while loop_counter > 0 :
15
- if increment :
16
- print character * loop_counter
17
- loop_counter += 1
18
- if loop_counter == size :
19
- # You've reached the top, start heading down the other side
20
- print character * loop_counter
21
- increment = 0
22
- else :
23
- loop_counter -= 1
24
- print character * loop_counter
13
+ for i in range (1 , size + 1 ):
14
+ print character * i
15
+ for i in range (size - 1 , 1 , - 1 ):
16
+ print character * i
25
17
26
18
27
19
create_pyramid (pyramid_character , pyramid_size )
You can’t perform that action at this time.
0 commit comments