Hello, lovely people, I was trying to understand the logic behind this and I failed I do not understand how this code runs and why it runs like this for me it is making no sense.
so we have a while statement … so we ask the user to start this car and user types start the car started and after he tries to type start again he sees the message that car already started … I have a problem understand that… why we do not do this in the simple logical way?
The user typed start message appear car started
if user types again we check if the car started? if yes we show a different message
what is the purpose of the started variable? I don’t understand HOW IT IS CONNECTED TO the code at all … why do we need that variable?
started = False
command = input(" ")
if command == “start”:
print(“car already started”)
started = True
what is stored in a started variable? it is just false so how it is connected to the car? Why did we change started variable to True in the else statement ?? it is confusing to me … and makes no logical sense … I thought python executed everything line by line … but from this, it seems not I know the code is working fine. this is logic that is logical. 1. Car started. 2. Is the car already started? Yes or not? Yes. The car already started, No, the car needs to start.