3 ms·
True, that's a problem I don't have anymore but it's a quick and understandable example of a mistake that I think lots of people had made before. Instead of a
by koube 8y ago
True, that's a problem I don't have anymore but it's a quick and understandable example of a mistake that I think lots of people had made before.
Instead of a comma I would actually recommend f-strings, which are python's string interpolation. The only downside is that the code within the f-strings I think have even less prechecking.
https://www.python.org/dev/peps/pep-0498/ https://www.python.org/dev/peps/pep-0498/
Example: print(f"There are {len(lights)} lights!")
- falcor84 8y agoI absolutely agree that f-strings are excellent for formatting, but I don't quite understand why you would use formatting in a regular print statement, when you could just stick to the commas and let the concatenation happen naturally in the output buffer? print("There are", len(lights), "lights!")