Source:
def draw_triangle(size, c='*', s=' '):
    o = ''
    for i in range(size):
        for j in range(size * 2):
            o += c if size + i == j or size - i == j or size - 1 == i and j else s
        o += '\n'
    return o
Sample Usage:
print draw_triangle(10);
"""
Outputs:
          *         
         * *        
        *   *       
       *     *      
      *       *     
     *         *    
    *           *   
   *             *  
  *               * 
 *******************
 """

Prints a triangle. If you took computer science, this are just one of those things that helps you learn programming.

Pythoneer 6 years ago