Nov-15-2020, 04:59 PM
Bello, I am learning about if statements. The question is to assign True or False to variables small and green. Then write some if/else statements to print which of these matches those choices; cherry, pea, watermelon and pumpkin.
Which of these two is better? Which is more pythonic?
Which of these two is better? Which is more pythonic?
small = True green = False if small and green: print("pea") elif small and not green: print("cherry") elif not small and green: print("watermelon") elif not small and not green: print("pumpkin")or
small = True green = False if small: if green: print("pea") else: print("cherry") else: if green: print("watermelon") else: print("pumpkin")