Issue
total = 0
number = 1
until = int(input("Until: "))
while total < until:
print(number, end = " + ")
total += number
number += 1
print(total)
Solution
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)
Answered By - Daniyal Ishfaq Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.