About 38,100,000 results
Open links in new tab
  1. loops - Looping a python "if" statement - Stack Overflow

    May 28, 2012 · I'm guessing a while loop, but when I try it just spits out my last print string infinitely. colour = input("black or white? ") if colour in ("black", "white"): print("Thank you") …

  2. Python If Statement - W3Schools

    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. In this example we use two variables, a and b, …

  3. How to Use IF Statements in Python (if, else, elif, and more ...

    Mar 3, 2022 · In Python, if statements are a starting point to implement a condition. Let’s look at the simplest example: When <condition> is evaluated by Python, it’ll become either True or …

  4. Python For Loop with If Statement - Spark By {Examples}

    May 30, 2024 · We can iterate blocks of code using for loop and using an if statement along with it we can check for a specific condition and perform until the condition is False. For loop iterates …

  5. Python Conditional Statements and Loops

    Read all the tutorials related to the topic of Python Sets. Loops in Python. Loops allow you to execute a block of code multiple times. Python provides two main types of loops: for loops and …

  6. Python - if , if..else, Nested if, if-elif statements - GeeksforGeeks

    Mar 7, 2025 · Below is the flowchart by which we can understand how to use if-else statement in Python: In this example, the code assigns the value 3 to variable x and uses an if..else …

  7. Mastering the if Loop in Python: A Comprehensive Guide

    Jan 21, 2025 · The if loop in Python is a fundamental and versatile tool for making decisions in your code. By understanding its basic concepts, various usage methods, common practices, …

  8. Python: For Loops, While Loops and If-Else Statements

    Feb 12, 2024 · This article will explain what is, how to make and use for loops, while loops and if-else statements in Python. A for-loop can be used to iterate through a range of numbers, …

  9. python - Pythonic way to combine for-loop and if-statement - Stack Overflow

    I know how to use both for loops and if statements on separate lines, such as: >>> a = [2,3,4,5,6,7,8,9,0] ... xyz = [0,12,4,6,242,7,9] ... for x in xyz: ... if x in a: ...

  10. 4. More Control Flow Tools — Python 3.13.3 documentation

    2 days ago · To iterate over the indices of a sequence, you can combine range() and len() as follows: In most such cases, however, it is convenient to use the enumerate() function, see …

Refresh