-1
price = int(input('Enter price. '))
quan = int(input('Enter quantity. '))
total = price*quan
print('The total is ' +str(total))
price2 = int(input('Enter price. '))
quan2 = int(input('Enter quantity. '))
total2 = price2*quan2
all_totals = total + total2
print('The sum of the totals is ' +str(all_totals))
理想情况下,我不想有price2等,但我需要程序来循环和加起来的小计,然后打印什么是总的。我是新来的python和任何帮助表示赞赏。谢谢!我该如何循环这段代码?
非常感谢!我现在知道了。我感谢您的帮助! –
upvoted。既然你在那里,也许,建议更好地使用'print' – Pynchia