Posted by: Sourav | December 20, 2016

An interesting pattern solved in Python,Python teacher Sourav,Kolkata 09748184075


import sys
S=’ABRAKADABRA’
k=0
for i in range(0,len(S)):
k=0
for j in range(((2*i)+1),0,-1):
k+=1

#print k
k-=1
for i in range(0,len(S)):
for j in range(k,0,-1):
sys.stdout.write(‘ ‘)
for j in range(((2*i)+1),0,-1):
sys.stdout.write(S[i])
sys.stdout.write(” “)

k-=2
print

##               T
##           R $ R $ R
##       Y $ Y $ Y $ Y $ Y
#    O $ O $ O $ O $ O $ O $ O
#U $ U $ U $ U $ U $ U $ U $ U $ U

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: