Py: Lesson 3

There is a “fruit” in each “riddle”.

Solve the riddles using an algorithm:

riddles = """Did you see a MAN GO by? He found his home lonely after his dog’s death. One dare not rob an anaconda of its prey. The crook made his escape armed with a gem. She told her uncle money was what she needed more. If I go out now, I shall miss my cousin. Either courage or anger made him move swiftly. The beggar held out his cap pleading for money. Matters regarding rape should be dealt differently. The English teacher Ryan teaches French too. He saw his papa yawning at work. He had kept on his lap lumpsum of money. Are classes for Telugu available in this city? It is easy to shape a child rather than a man. He is an extremely cheesy guy. Can I wear a khaki with a black shirt?""" fruit = """Açaí Ackee Apple Apricot Avocado Banana Bilberry Blackberry Blackcurrant Black sapote Blueberry Boysenberry Breadfruit Buddha's hand (fingered citron) Cactus pear Crab apple Currant Cherry Cherimoya (Custard Apple) Chico fruit Cloudberry Coconut Cranberry Damson Date Dragonfruit (or Pitaya) Durian Elderberry Feijoa Fig Goji berry Gooseberry Grape Raisin Grapefruit Guava Hala Fruit Honeyberry Huckleberry Jabuticaba Jackfruit Jambul Japanese plum Jostaberry Jujube Juniper berry Kiwano (horned melon) Kiwifruit Kumquat Lemon Lime Loganberry Loquat Longan Lychee Mango Mangosteen Marionberry Melon Cantaloupe Galia melon Honeydew Watermelon Miracle fruit Monstera Delisiousa Mulberry Nectarine Nance Orange Blood orange Clementine Mandarine Tangerine Papaya Passionfruit Peach Pear Persimmon Plantain Plum Prune (dried plum) Pineapple Pineberry Plumcot (or Pluot) Pomegranate Pomelo Purple mangosteen Quince Raspberry Salmonberry Rambutan (or Mamin Chino) Redcurrant Salal berry Salak Satsuma Soursop Star apple Star fruit Strawberry Surinam cherry Tamarillo Tamarind Tangelo Tayberry Ugli fruit White currant White sapote Yuzu Bell pepper Chile pepper Corn kernel Cucumber Eggplant Jalapeño Olive Pea Pumpkin Squash Tomato Zucchini"""

Some tools you’ll want:

  • string.find(substring) => index or -1
  • string.lower() => lowercase version of string
  • string.upper() => uppercase version of string
  • string.replace(old, new) => newString
  • string.split(“\n”) => list of strings split at line breaks

Fruit Challenge.py