About 258,000 results
Open links in new tab
  1. python - Putting a simple if-then-else statement on one line - Stack ...

    How do I write an if - then - else statement in Python so that it fits on one line? For example, I want a one line version of:

  2. python - Putting an if-elif-else statement on one line? - Stack Overflow

    Dec 25, 2012 · Is there an easier way of writing an if-elif-else statement so it fits on one line? For example, if expression1: statement1 elif expression2: statement2 else: statement3 Or a real-world

  3. python - Spark Equivalent of IF Then ELSE - Stack Overflow

    8 There are different ways you can achieve if-then-else. Using when function in DataFrame API. You can specify the list of conditions in when and also can specify otherwise what value you need. You …

  4. Does Python have a ternary conditional operator?

    Dec 27, 2008 · If you're having trouble remembering the order, then remember that when read aloud, you (almost) say what you mean. For example, x = 4 if b > 8 else 9 is read aloud as x will be 4 if b is …

  5. Else clause on Python while statement - Stack Overflow

    Jul 21, 2010 · The better use of 'while: else:' construction in Python should be if no loop is executed in 'while' then the 'else' statement is executed. The way it works today doesn't make sense because …

  6. Python if-else short-hand - Stack Overflow

    Jan 22, 2013 · The "Zen of Python" says that "readability counts", though, so go for the first way. Also, the and-or trick will fail if you put a variable instead of 10 and it evaluates to False.

  7. python - Creating if/else statements dependent on user input - Stack ...

    Creating if/else statements dependent on user input Asked 11 years, 1 month ago Modified 1 year, 8 months ago Viewed 51k times

  8. python - if/else in a list comprehension - Stack Overflow

    if/else statements in list comprehensions involve two things: List comprehensions Conditional expressions (Ternary operators) 1. List comprehensions They provide a concise way to create lists. …

  9. Using 'or' in an 'if' statement (Python) - Stack Overflow

    Using 'or' in an 'if' statement (Python) [duplicate] Asked 7 years, 10 months ago Modified 2 months ago Viewed 162k times

  10. python - What is the correct syntax for 'else if'? - Stack Overflow

    One reason very old languages use this distinct syntax instead of "else if" is that the "else if" introduces a grammar ambiguity. Old parser generators were hard to teach about what to do for ambiguities, so …