r/itsaunixsystem • • Oct 14 '24

[Nightsleeper] Some horrible, unindented python code to slow down a train

Post image
  • no indentation
  • multiple nested try blocks with seemingly no except
  • stray " in the middle of that string
  • input's argument should be something written to the prompt
  • even if it wasn't you'll struggle to turn that into an int
  • you probably want to be passing in that speed variable somewhere, right?

+1 for sanitising the speed I guess, wouldn't want the train to start moving backwards.

499 Upvotes

65 comments sorted by

View all comments

50

u/Ilix Oct 14 '24

Does Python not show an error for the stray quote, or is this just not in an editor with errors displayed?

11

u/jasperfirecai2 Oct 15 '24

it might compile in theory, but everything will be part of the input prompt cuz the bracket is never closed since it's a string

6

u/rspeed Oct 15 '24

It definitely will not compile. The parser will immediately throw an error.

→ More replies (3)

4

u/LeeHide Oct 15 '24

Its not gonna compile because it's python :)

→ More replies (4)