A simple kata from codewars will show us how to use the if-else statement in python.

The wide mouth frog is particularly interested in the eating habits of other creatures.

He just can’t stop asking the creatures he encounters what they like to eat. But then he meets the alligator who just LOVES to eat wide-mouthed frogs!

When he meets the alligator, it then makes a tiny mouth.

Your goal in this kata is to create the complete the mouth_size method this method takes one argument animal which corresponds to the animal encountered by the frog. If this one is an alligator (case insensitive) return small otherwise return wide.

def mouth_size(animal): 
  if animal.lower() == "alligator":
      return "small"
  else:
      return "wide"

As you can see, if the animal is an alligator then the function will return “small” mouth, or else “wide” mouth will be returned!

I have started to write again, not just about the programming topic but also about other topics such as web development, browser and online business on this website, therefore stay tuned for more interesting stuff in the future!

Click to rate this post!
[Total: 1 Average: 5]
Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *