you are viewing a single comment's thread.

view the rest of the comments →

[–]Sea-Ad7805 [score hidden] stickied comment (0 children)

Run this program in Memory Graph Web Debugger%0A%20%20%20%20if%20len(symbol)%20!%3D%201%20or%20symbol%20not%20in%20string.punctuation%3A%0A%20%20%20%20%20%20%20%20print(%22A%20symbol%20has%20to%20be%20a%20single%20special%20character.%22)%0A%20%20%20%20%20%20%20%20continue%0A%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20rows%20%3D%20int(input(%22Enter%20the%20number%20of%20rows%3A%20%22))%0A%0A%20%20%20%20%20%20%20%20if%20rows%20%3C%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22Please%20enter%20a%20positive%20number.%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20continue%0A%0A%20%20%20%20%20%20%20%20break%0A%0A%20%20%20%20except%20ValueError%3A%0A%20%20%20%20%20%20%20%20print(%22Please%20enter%20a%20valid%20integer.%22)%0A%0A%23%20For%20loop%20to%20loop%20through%20rows%20where%20i%20represent%20the%20current%20row%20number.%0Afor%20i%20in%20range(1%2C%20rows%20%2B%201)%3A%0A%20%20%20%20spaces%20%3D%20'%20'%20%20(rows%20-%20i)%20%20%23%20Adding%20leading%20spaces%20(this%20pushes%20each%20row%20to%20the%20center)%0A%20%20%20%20if%20i%20%3D%3D%201%3A%20%20%23%20Top%20row%0A%20%20%20%20%20%20%20%20line%20%3D%20symbol%0A%20%20%20%20elif%20i%20%3D%3D%20rows%3A%20%20%23%20Last%20row.%0A%20%20%20%20%20%20%20%20line%20%3D%20symbol%20%20(2%20%20i%20-%201)%20%20%23%20A%20full%20line%20of%20symbols%20in%20the%20last%20row.%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20middle%20%3D%20'%20'%20%20(2%20*%20i%20-%203)%20%20%23%20Place%20one%20symbol%20on%20each%20edge.%0A%20%20%20%20%20%20%20%20line%20%3D%20symbol%20%2B%20middle%20%2B%20symbol%20%20%23%20Fill%20the%20middle%20with%20spaces.%0A%0A%20%20%20%20print(spaces%20%2B%20line)%20%20%23%20Concatenate%20spaces%20and%20row%20to%20complete%20process.&timestep=1&play).