[Tutor] Tutor Digest, Vol 161, Issue 41

Alan Gauld alan.gauld at yahoo.co.uk
Sun Jul 30 18:40:57 EDT 2017

On 30/07/17 19:50, Borisco Bizaro wrote:
> Please I have been ask to write python code that ask user to enter a price
> continuetly until key press to and give the total amount of price I have
> enter using while loop I don't know how to go about it

First of all, please do not send the whole digest to the list
 - some people pay by the byte and we've all seen it already.

Second, we solve programming challenges by breaking them down
into small parts and solving each part.

Third we don't do homework for you, but we can point you
in the right direction.

So, looking at your problem...

> ...write python code that ask user to enter a price

Do you know how to do that bit? get the usr to enter
a price and store (or print) the value?

> continuetly until key press

We'll come back to this.

> to and give the total amount of price

Do you know how to get the total of a list of prices?
For exanmple if I say

prices = [12, 13.00, 24.50. 17. 5.30]

Can you print the total of prices?

> enter using while loop

This ties in with the earlier requirement:

> enter using while loop
> continuously until key press

Lets assume the "keypress" is 0.
Do you know how to write a while loop that terminates
when an input value is 0?

Let us know the answers and we can point you
a little further towards solving the problem.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list