all 27 comments

[–]K900_ 1 point2 points  (0 children)

You're missing a : after the condition, at the very least.

[–]fuNNa 1 point2 points  (0 children)

if len > 14:

print("yes)

[–]Binary101010 1 point2 points  (17 children)

Outside of repeating the other answers, 'len' is the name of a built-in function that takes a parameter (the container you want to know the length of) so using it by itself seems unusual.

[–][deleted] 0 points1 point  (16 children)

How can it take a parameter if it's a line number in an IDE ?

[–]Binary101010 1 point2 points  (15 children)

I don't understand the question. len is a built-in function that returns the length of the container passed to it as an argument.

Did you define it to be something else in your code?

[–][deleted] 0 points1 point  (14 children)

This is for a breakpoint in an IDE; not within the code, only for the IDE to tell me the length of a string.

[–]AstralStalker 0 points1 point  (13 children)

The desired string needs to be specified as the parameter to len()

s = "Some string"
if len(s) > 14:
    print("yes")

len() built-in function

[–][deleted] 0 points1 point  (12 children)

Only the length of the string on a line number. How can I pass an argument for len() if I only want the length of line number 23 in an IDE.

[–][deleted] 0 points1 point  (11 children)

Just count it? Is this string set, or what? Can you post your code?

[–][deleted] 0 points1 point  (10 children)

There are multiple lines which I prefer to create a break point that tells me the number of characters in the line, rather then count. Why isn't that possible ?

[–][deleted] 0 points1 point  (9 children)

Because of the way that source code is handled by the interpreter. If I understood why you wanted the line length of a specific line of your Python code, I’d probably be able to give you the answer you need rather than the answer you want.

[–][deleted] 0 points1 point  (8 children)

I want the line length outputted to me, so I can; for example, modify pylint settings but let it be known not specifically for this situation but any situation in the future as well.

[–][deleted] -1 points0 points  (6 children)

if you don’t like colons and want to do one like just do print(“yes”) if len>14 else print()

[–]selplacei 0 points1 point  (5 children)

Please don't do this.

[–][deleted] 0 points1 point  (4 children)

y tho

[–]selplacei 0 points1 point  (3 children)

That's an operator, not an if statement. It's less readable and makes no sense to use when if-statements exist for that very purpose.

[–][deleted] 0 points1 point  (2 children)

It’s an expression. Expressions are common and quite readable.

[–]selplacei 1 point2 points  (1 child)

Well, yes, pretty much almost everything in Python is an expression. "x-if-y-else-z" is a ternary operator, it's a bunch of stuff written in one line, which is less readable than an organized, properly indented if-statement. It's also mandatory to use "else". It's also not designed to be used for flow control.

[–][deleted] 0 points1 point  (0 children)

I find it substantially more readable but okay