Alphabet Pattern 'K' in Python

Code:
  1. str="";    
  2. j = 5;    
  3. i = 0;  
  4. for Row in range(0,7):    
  5.     for Col in range(0,7):     
  6.         if (Col == 1 or ((Row == Col + 1and Col != 0)):  
  7.             str=str+"*"    
  8.         elif (Row == i and Col == j):  
  9.               str=str+"*"    
  10.               i=i+1  
  11.               j=j-1  
  12.         else:      
  13.             str=str+" "    
  14.     str=str+"\n"    
  15. print(str);    
Output:

 
Ebook Download
View all
Learn
View all
sourabhsomani.com