On 02/08/17 20:53, Borisco Bizaro wrote: > I try this using loop but could not stop by pressing a key and could not > give total price please help me
It would help if you showed us the code you wrote with the loop. Its difficult to guess what you did wrong when we can't see it. > print"\n welcome to progrom that print total price\n" > a=int(input("enter the first price: ")) > b=int(input ("enter another price: ")) > c=int(input ("enter another price: ")) > d=int(input ("enter another price: ")) > f=int(input ("enter another price: ")) > g=int(input ("enter another price: ")) > h=int(input ("enter another price: ")) > total=a+b+c+d+f+g+h Here is a hint... You could collect the prices in a list then use sum() to get the total. Then your loop only needs to read a value and append() it to the list. break out of the loop if the user enters 0, or -1, or whatever you want to stop it. > print"\n totol",a+b+c+d+f+g+h > print("\n\n press the o key to exit ") Notice one print uses parentheses, the other doesn't. Which version of Python are you using? Its better if you stick to one form or the other as appropriate to your Python version. > This is what I did but could not be able to used while loop > On Jul 30, 2017 23:44, <tutor-requ...@python.org> wrote: > > Send Tutor mailing list submissions to > tutor@python.org > Please delete the digest material (it wastes bandwidth and costs some folks money) and change the subject line to something hewlpful, as suggested here... > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor