Simple Python - Error in Programming
Question: I've been stuck on this issue for over two hours, this is homework so please
don't give me a direct answer just point me in the right direction.

So... This program is designed to input a "speed limit", input "Current speed"
and give you a print response of either "Speed OK" (if you are below or equal
to the speed limit) and "Slow down!" (if you are speeding). When I input the
following data, as required on the task: Speed Limit of 50. Current Speed of
50, 45, 55, 52, and 50.

The answer should read -

    
    
    Speed limit: 50
    Current speed: 50
    Speed OK
    Current speed: 45
    Speed OK
    Current speed: 55
    Slow down!
    Current speed: 52
    Slow down!
    Current speed: 50
    Speed OK
    Current speed:(White space)
    

Instead I get -

    
    
    Current speed: 50
    Speed OK
    Current speed: 45
    *Then the program stops.*
    

My Program Reads -

    
    
    limit = int(input("Speed limit: "))
    speed = int(input("Current speed: "))
    if speed <= limit:
      print("Speed OK")
      speed = int(input("Current speed: "))
    false = speed > limit
    while false:
      print("Slow down!")
      speed = int(input("Current speed: "))
    

If somebody could point me in the right direction that would be wonderful ;).

Cheers,

Ron


Answer: First of all, keep in mind that the one of the most important rules of
programming is to avoid code doubling. This means that it nearly _never_ a
good idea to have the same `speed = int(input("Current speed: "))` line three
times in your program. If there's an error in that line, fixing it will
probably leave the error in the two other places untouched.

If you follow that rule, you will probably find out that you only need one
loop which should terminate on `(White space)` (so this check should be in the
condition, not `false`). And _inside_ that loop you should check with `if`
which response your program should give.

Finally, I _strongly_ disapprove of having a variable named `false`. In case
`speed` is larger than `limit`, your variable `false` will hold the value
`True` (which is quite peculiar and surprising). Any other programmer would
probably misunderstand this.

Never forget that writing a program also is communicating with the next
programmer who has to maintain your code.

