The syntax of "if" requires two elements, a condition and an indented block of statements. The indented block can have any number of statements, which can be any sort of valid Python statement, even including another "if" statement. The code shown here is a function to determine whether or not a number is odd and has the number 6 somewhere in its decimal representation. The indented block of the first if starts with the definition of digits, whereas the indented block of the nested if is the return True statement.

1
2
3
4
5
6
def oddsix(number):
  if number%2 == 1:
     digits = str(number)
     if "6" in digits:
        return True
  return False 

Instead of writing oddsix this way, an equivalent formulation would be this simple four-line function.

1
2
3
4
def oddsix(number):
  if (number%2 == 1) and "6" in str(number):
     return True
  return False

Yet simpler is a two-line function:

1
2
def oddsix(number):
  return (number%2 == 1) and "6" in str(number)