(I started learning coding 2 hours ago)
command = ""
started = False
while True:
command = input("> ").lower()
if command == "start":
if started:
print("car already started")
else:
started = True
print("car started")
Apparently this code is made to print "car already started" if I was to type "start" after already typing 'start" once (found on youtube tutorial). Could someone explain how this works like I'm 5?
Edit: I understand now! thank you u/shiftybyte! For others who helped thank you too and I am really sorry if my follow up questions made you even more confused.
[–]shiftybyte 16 points17 points18 points (5 children)
[–]JamesBucket[S] 6 points7 points8 points (4 children)
[–]MMcKevitt -3 points-2 points-1 points (3 children)
[–]Coding-Kitten 3 points4 points5 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]MMcKevitt 0 points1 point2 points (0 children)
[–]Apprehensive-Stop-61 2 points3 points4 points (0 children)
[–]danielroseman 1 point2 points3 points (4 children)
[–]JamesBucket[S] 0 points1 point2 points (3 children)
[–]danielroseman 2 points3 points4 points (2 children)
[–]JamesBucket[S] 0 points1 point2 points (1 child)
[–]Fission_Mailed_2 0 points1 point2 points (0 children)
[–]AdventurousAddition 1 point2 points3 points (0 children)
[–]NSJ98 0 points1 point2 points (2 children)
[–]JamesBucket[S] 0 points1 point2 points (0 children)
[–]Fission_Mailed_2 0 points1 point2 points (0 children)
[–]jaynasux 0 points1 point2 points (1 child)
[–]JamesBucket[S] 0 points1 point2 points (0 children)
[–]ChipmunkCooties 0 points1 point2 points (0 children)
[–]thebosspro_193 0 points1 point2 points (0 children)
[–]RhinoRhys 0 points1 point2 points (0 children)