About 632,000 results
Open links in new tab
  1. If statement for strings in python? - Stack Overflow

    "input() evaluates whatever is entered as a Python expression, raw_input() returns a string." Except in Python 3, where input() does what raw_input() used to, and you'd use eval(input()) or something if you wanted the input to be evaluated as a Python expression.

  2. Using or in if statement (Python) - Stack Overflow

    I have a condition for an if statement. It should evaluate to True if the user inputs either "Good!" or "Great!". The code is as follows: weather = input("How's the weather?

  3. Python - Using string as condition in if statement

    May 5, 2013 · I am trying to do this: a = "1 or 0" if (a): Print "true" So I can use a string as the condition of an if statement. Is this possible?

  4. Python if OR - GeeksforGeeks

    Dec 18, 2024 · In Python, if statement is the conditional statement that allow us to run certain code only if a specific condition is true . By combining it with OR operator , we can check if any one of multiple conditions is true, giving us more control over our program.

  5. if Statement With Strings in Python - Delft Stack

    Feb 22, 2025 · Learn how to effectively use the if statement with strings in Python in this comprehensive guide. Explore various techniques for string comparison, including case-insensitive checks and membership testing using the in keyword.

  6. Logical Operations on String in Python - GeeksforGeeks

    Nov 5, 2024 · Python logical operators are used to combine conditional statements, allowing you to perform operations based on multiple conditions. These Python operators, alongside arithmetic operators, are special symbols used to carry out computations on values and variables.

  7. Conditional Statements in Python - GeeksforGeeks

    Apr 4, 2025 · Conditional statements in Python are used to execute certain blocks of code based on specific conditions. These statements help control the flow of a program, making it behave differently in different situations.

  8. Python Conditions - W3Schools

    Python supports the usual logical conditions from mathematics: These conditions can be used in several ways, most commonly in "if statements" and loops. An "if statement" is written by using the if keyword. If statement: In this example we use two variables, a and b, which are used as part of the if statement to test whether b is greater than a.

  9. Python Conditional Statements and Loops

    Conditional Statements in Python. Conditional statements allow your program to make decisions based on certain conditions, executing different blocks of code depending on whether these conditions evaluate to True or False. The if Statement. The most basic conditional statement is the if statement: # Basic if statement x = 10 if x > 5: print("x ...

  10. How to Use Conditional Statements in Python – Examples of if, …

    Mar 7, 2023 · In this article, we'll explore how to use if, else, and elif statements in Python, along with some examples of how to use them in practice. The if statement allows you to execute a block of code if a certain condition is true. Here's the basic syntax: The condition can be any expression that evaluates to a Boolean value (True or False).

  11. Some results have been removed
Refresh