Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Python3
- #Example 1
- for i in range(-3,4):
- print('*'+(' '*abs(i**2-3))+'*') if i>-3 and i<3 else print('*')
- #Skip Lines
- print('\n\n')
- #Example 2
- for i in range(-2,3):
- print((' '*abs(i*2))+'*'+(' '*(-(abs(4*i))+7))+'*') if i>-2 and i<2 else print((' '*abs(i)*2)+'*')
- #Skip Lines
- print('\n\n')
- #Alternate approach to Example 1
- a=['*']*7
- for i in range(0,len(a)-1):
- a[i+1] = '*'+(' '*(i+1))+'*'
- if i>3: a[i]= '*'+(' '*(6-i))+'*'
- print(a[i])
- if i==5: print('*')
- #Output
- """
- *
- * *
- * *
- * *
- * *
- * *
- *
- *
- * *
- * *
- * *
- *
- *
- * *
- * *
- * *
- * *
- * *
- *
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement