On 2019-10-28 06:42:46 -0700, ferzan saglam wrote: > How can I stop this code when -1 is typed or at a maximum item count of ten.
I'm just rewriting that sentence in Python:
> At the moment the code seems to be in a infinite loop meaning it keeps on
> asking for an entry until -1 is typed
>
>
> total = 0
> while True:
>
> print('Cost of item')
>
> item = input()
>
> if item != -1:
> total = total + item
> if item == -1:
if item == -1 or count > 10:
>
> break
>
> print(total)
Now it is up to you increment the variable count for each item.
Does that help?
hp
--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | [email protected] | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list
