[Tutor] Trouble with SUM()
Steven D'Aprano
steve at pearwood.info
Sat Apr 20 20:17:15 EDT 2019
On Sat, Apr 20, 2019 at 04:51:11PM -0400, Ju Bo wrote:
> con = "y"
> while con == "y":
> AMT = float(input("What is the price of the item? $"))
> con = input("Would you like to continue? [y/n]")
> price = float(sum(AMT + AMT))
That's a good first attempt.
Rather than set the price to float(sum(AMT + AMT)), which doesn't work,
set the price to 0 before the loop starts. Then each time through the
loop, set the price to price + AMT:
price = price + AMT
--
Steven
More information about the Tutor
mailing list