String Python-3.6如何在每次输入结束时而不是之后打印所有结果?

String Python-3.6如何在每次输入结束时而不是之后打印所有结果?,string,python-3.x,loops,int,output,String,Python 3.x,Loops,Int,Output,对不起,伙计们,我不知道怎么解决这个问题 程序获取一系列独立的随机整数输入,将每个新整数与前一个整数进行比较(更高、更低、相等):例如,第一个数字=10,下一个数字=5,输出=更低。此循环直到用户输入[0] 但我现在想更改它,以便所有输出都位于末尾,而不是每对后1个。假设总体输入为2,3,6,6,5,1[0]:print语句应仅在[0]之后,即较高等于较低(全部在一条语句中) 我尝试过的事情。。。打印(a),但当然(a)会被重新分配给每个新号码。。。。。尝试(新手错误):如果ba: #打印(“更

对不起,伙计们,我不知道怎么解决这个问题

程序获取一系列独立的随机整数输入,将每个新整数与前一个整数进行比较(更高、更低、相等):例如,第一个数字=10,下一个数字=5,输出=更低。此循环直到用户输入[0]

但我现在想更改它,以便所有输出都位于末尾,而不是每对后1个。假设总体输入为2,3,6,6,5,1[0]:print语句应仅在[0]之后,即较高等于较低(全部在一条语句中)


我尝试过的事情。。。打印(a),但当然(a)会被重新分配给每个新号码。。。。。尝试(新手错误):如果b
z = 0
done = False
a = int(input("Enter first number: "))
track_comparisons = []
while not done:
    b = int(input("Enter next number [0 = done]: "))
    if b != z: #while program not done
        if b > a:
            track_comparisons.append('higher')
        elif b == a:                       #change to if, elif, else
            track_comparisons.append('equal')
        else:
            track_comparisons.append("lower")
        a = b #second number becomes first and repeat
    else:
        for response in track_comparisons:
            print(response, end=' ')
        done = True

跟踪响应,最后打印

z = 0
done = False
a = int(input("Enter first number: "))
track_comparisons = []
while not done:
    b = int(input("Enter next number [0 = done]: "))
    if b != z: #while program not done
        if b > a:
            track_comparisons.append('higher')
        elif b == a:                       #change to if, elif, else
            track_comparisons.append('equal')
        else:
            track_comparisons.append("lower")
        a = b #second number becomes first and repeat
    else:
        for response in track_comparisons:
            print(response, end=' ')
        done = True
试试下面的方法-

z = 0
ans = []
done = False
a = int(input("Enter first number: "))
while not done:
    b = int(input("Enter next number [0 = done]: "))
    if b != z: #while program not done
        if b > a:
            #print("higher")
            ans.append("higher")
        if b == a:
            #print("equal")
            ans.append("equal")
        if b < a:
            #print("lower")
            ans.append("lower")
        a = b #second number becomes first and repeat
    else:
        done = True

print(ans)
z=0
ans=[]
完成=错误
a=int(输入(“输入第一个数字:”)
虽然没有这样做:
b=int(输入(“输入下一个数字[0=done]:”)
如果b!=z:#程序未完成时
如果b>a:
#打印(“更高”)
ans.append(“更高”)
如果b==a:
#打印(“相等”)
附加(“相等”)
如果b
尝试以下操作-

z = 0
ans = []
done = False
a = int(input("Enter first number: "))
while not done:
    b = int(input("Enter next number [0 = done]: "))
    if b != z: #while program not done
        if b > a:
            #print("higher")
            ans.append("higher")
        if b == a:
            #print("equal")
            ans.append("equal")
        if b < a:
            #print("lower")
            ans.append("lower")
        a = b #second number becomes first and repeat
    else:
        done = True

print(ans)
z=0
ans=[]
完成=错误
a=int(输入(“输入第一个数字:”)
虽然没有这样做:
b=int(输入(“输入下一个数字[0=done]:”)
如果b!=z:#程序未完成时
如果b>a:
#打印(“更高”)
ans.append(“更高”)
如果b==a:
#打印(“相等”)
附加(“相等”)
如果b
这很好,谢谢。但它有两个问题:在“equal”(如5和5)上出现错误,并随响应一起重新启动程序。不幸的是,我的编码技能不够高,不知道为什么!再次检查,我不小心放了append.append,这里应该只有一个append。是的,现在它工作得很好。非常感谢。奇怪的是,一点点的差别。附加就能产生效果!这很好,谢谢。但它有两个问题:在“equal”(如5和5)上出现错误,并随响应一起重新启动程序。不幸的是,我的编码技能不够高,不知道为什么!再次检查,我不小心放了append.append,这里应该只有一个append。是的,现在它工作得很好。非常感谢。奇怪的是,一点点的差别。附加就能产生效果!我不知道为什么这个答案是-1,因为它非常接近于我所寻找的,并且不会使程序过于复杂,这是一个加号。唯一的区别是我想要一个输出,比如:越高越低等于。。。我不知道为什么这个答案是-1,因为它几乎符合我的要求,不会使程序过于复杂,这是一个加号。唯一的区别是我想要一个输出,比如:越高越低等于。。。而不是['higher'],['higher'],['lower'],[equal],。。。。