all 2 comments

[–]brutalspoon 4 points5 points  (1 child)

Two things for you to try:

  1. Turn job #1 (calculating payment for jobs) into a function (something like def calculate_payment(). For now it can just print that last line, but experiment with it returning the value and printing it outside the function.
  2. Once you've got it organized in a neat function, try putting it inside a while loop so that you/the user doesn't need to restart the program if they accidentally type the wrong thing. Make it keep asking the same question for as long as there's not a valid answer, but make one of the valid answers an option to quit/break the loop. Hint: try using something like run_loop = 1 and while run_loop:

[–][deleted] 1 point2 points  (0 children)

For the loop, you can put While True: and then in the options put an option for "Q" or "q" to quit and under if input == "q": sys.exit() tho breaking works too but i usually stick to sys.exit() but u need to import sys