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

    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: if count == N: count = 0 else: count = N + 1 In Objective-C, I wo...

  2. 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 …

  3. Creating a new column based on if-elif-else condition

    I'm an old SAS user learning Python, and there's definitely a learning curve! :-) For example, the above code could be written in SAS as: data df; set df; if A=B then C=0; else if A>B then C=1; …

  4. python - How to assign a variable in an IF condition, and then …

    Apr 27, 2019 · The one liner doesn't work because, in Python, assignment (fruit = isBig(y)) is a statement, not an expression. In C, C++, Perl, and countless other languages it is an …

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

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

  6. What is Python's equivalent of && (logical-and) in an if-statement?

    Mar 21, 2010 · There is no bitwise negation in Python (just the bitwise inverse operator ~ - but that is not equivalent to not). See also 6.6. Unary arithmetic and bitwise/binary operations and …

  7. python - How to use conditional if statements in Jinja 2 ... - Stack ...

    So I am new to Django and can use some help. I have used a for loop to display a list from my database. But I want to add an if statement such that, if the user input matches my database …

  8. python - How to use if and else statements to achieve Age …

    I have an assignment in my Python class. It says: Write a program that asks the user to enter a person's age. The program should display a message indicating whether the person is an …

  9. The equivalent of a GOTO in python - Stack Overflow

    Python (like almost every programming language today) supports structured programming which controls flow using if/then/else, loop and subroutines. The key to thinking in a structured way is …

  10. performance - Python if statement efficiency - Stack Overflow

    Aug 3, 2012 · A friend (fellow low skill level recreational python scripter) asked me to look over some code. I noticed that he had 7 separate statements that basically said.