About 7,500,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 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 …

  3. Python For Loops and If Statements Combined (Data Science …

    Apr 11, 2018 · In this article, I’ll show you – through a few practical examples – how to combine a for loop with another for loop and/or with an if statement! Note: This is a hands-on tutorial. I …

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

    May 30, 2024 · Using for loop with an if statement in Python, we can iterate over a sequence and perform different tasks for each item in a sequence until the condition falls a False. Let’s take …

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

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

    Jan 26, 2025 · Whether you're a beginner taking your first steps in programming or an experienced developer looking to refresh your knowledge, understanding the if loop is …

  7. 4. More Control Flow Tools — Python 3.15.0a0 documentation

    4 days ago · When used with a loop, the else clause has more in common with the else clause of a try statement than it does with that of if statements: a try statement’s else clause runs when …

  8. Loops | CBSE Python Notebooks

    Conditional operations can be performed in Python using if statements. An "if statement" is written by using the if keyword. Copy a = 33 b = 200 ... One of the advantages of using computer to …

  9. Conditional Statements in Python - GeeksforGeeks

    Apr 4, 2025 · elif statement in Python stands for "else if." It allows us to check multiple conditions , providing a way to execute different blocks of code based on which condition is true. Using elif …

  10. 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, …

Refresh