Home > database >  how to replace the last with =?
how to replace the last with =?

Time:04-07

total = 0
number = 1
until = int(input("Until: "))

while total < until:
    print(number, end = "   ")
    total  = number
    number  = 1

print(total)

CodePudding user response:

You have to add a condition to check whether you have reached the end of loop and then print '=' in that case. Something like this.

total = 0

number = 1

until = int(input("Until: "))

while total < until:
    total  = number

    if total >= until:
        print(number, end=" = ")
    else:
        print(number, end = "   ")

    number  = 1
print(total)
  • Related