Python-Druckfunktion mehrfach ausgeben

Ich mache ein Programm, um ein @ zu erreich bestimmte Python-Herausforderung. Ich habe das Programm erstellt und es tut im Grunde alles, wofür ich es brauche, außer dass es eine seltsame Eigenart hat. es druckt die Ausgabe, die ich will, mehrmals.

cmdname = input("Enter the name of your command.\n>")
print("Enter options one by one. If the option has an argument, put a * at the end of the option. When done entering options, enter \"q\".")
oplist = ""
oplist += cmdname + " " 
def prgm(): 
    global oplist
    while 2 + 2 == 4:
        user = input(">")
        if user[0] == "-":
            if "*" in user:
                oplist += user[0:len(user) - 1] + " " 
                print("Now, enter the option's argument.")
                user = input(">")
                oplist += user[0:len(user) - 1] + " " 
                print("Option successfully added.")
                prgm()
            else: 
                oplist += user + " " 
                print("Option successfully added.")
                prgm()
        elif user == "q":
            print("Enter the command argument.")
            user = input(">")
            oplist += user
        else:
            print("Error. You didn't enter an option.")
            prgm()
        break
    print(oplist)
prgm()

Die Häufigkeit, mit der die Ausgabe gedruckt wird, scheint davon abzuhängen, wie viele Optionen der Benutzer angibt, aber ich weiß nicht, warum. Wenn ich das Programm in IDLE ausführe und nach Beendigung der Funktion manuell drucke (oplist), druckt IDLE die Ausgabe einmal in einer Zeile, wie ich es beabsichtigt hatte. Warum genau ist das so?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage