Skip to content
Advertisement

Wanting to input bowling scores, total, average them

Need for a user to input bowling scores and store them, to be totaled and averaged later and they can press “q” or “Q” to quit and total/average them. I’ve tried fumbling around figuring out loops but not sure how to deal with inputting integers and also accepting “Q” to stop loop. Thanks for any help.

JavaScript

Getting error: Traceback (most recent call last): File “/Users/ryaber/PycharmProjects/pythonProject/main.py”, line 11, in scores = input(“Please enter a score (xxx) or ‘q’ to exit: “) File “”, line 1, in NameError: name ‘q’ is not defined

So not sure how to allow it to accept “Q” to stop loop and total/average them.

Advertisement

Answer

  1. Remove .lower() in q.lower() and move it and make it to score.lower(). So if user types in q or Q both will be accepted as quit

  2. You do not need average function or while scores != 'q' instead you could change it to something simple

So complete code –

JavaScript

Result:

JavaScript

Edit – While this may be complicated, this will solve your problem –

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement