CodyKochmann
6/7/2016 - 9:19 PM

multiline input for the command line in python

multiline input for the command line in python

def multiline_input(prompt=""):
    """ gets a multiline input from the user in the command line """
    """ by: Cody Kochmann """
    print(prompt)
    out=[]
    len_before_previous=1
    previous_len=1
    while previous_len > 0 and len_before_previous>0:
        current=raw_input("")
        if current != "":
            out.append(current)
        len_before_previous=previous_len
        previous_len=len(current)
    # remove empty lines from arguments
    for i in list(out):
        if len(i) == 0:
            out.remove(i)
    return(out)