#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목[re]quiz loop안쓰고 어떻게 하는지 제발 알려주세요 ㅠ2018-10-17 23:45
작성자

셀프로 알아냈어요

# 함수 정의

def makeTree(shape, width,rain):

    

    output = ''

    

    if rain == True:

        output += '/'*int(width)+"n"

        output += shape.center(width,'/')+"n"

        output += (3*shape).center(width,'/')+"n"

        output += (5*shape).center(width,'/')+"n"

        output += (7*shape).center(width,'/')+"n"

        output += (9*shape).center(width,'/')+"n"

        output += (11*shape).center(width,'/')+"n"

        output += ('    |||    ').center(width,'/')+"n"

        output += (width*"=").center(width)

        

    else:

        output += shape.center(width)+"n"

        output += (3*shape).center(width)+"n"

        output += (5*shape).center(width)+"n"

        output += (7*shape).center(width)+"n"

        output += (9*shape).center(width)+"n"

        output += (11*shape).center(width)+"n"

        output += (3*'|').center(width)+"n"

        output += (width*"=").center(width)

            


    

    return output


혹시 다른방법도 있나요.. 이런 노가다 말고 loop 안쓰는 방법..

댓글