Tag: Loops & control flow

  • Python’s “else” clause for loops

    Let’s say that we have a list of tuples, with each tuple containing some numbers. For example: >>> mylist = [(3,5), (2,4,6,8), (4,10, 17), (15, 14, 11), (3,3,2)] I want to write a program that asks the user to enter a number. If one of the tuples adds up to the user’s input, we’ll print…

    Read more