Maybe a stupid question but, how do I write the below code in python 3.5.2 idle shell?
The problem is functions (def) are always 4 spaces indented below class and there is one row space between def functions. If I try to do the same in idle it jumps to a new line (after the first def) and even if I start the new function with 4 space indent it is no longer recognised as part of class function sequence!
please help me!
class Fruit(object): """A class that makes various tasty fruits.""" def __init__(self, name, color, flavor, poisonous): self.name = name self.color = color self.flavor = flavor self.poisonous = poisonous def description(self): print "I'm a %s %s and I taste %s." % (self.color, self.name, self.flavor) def is_edible(self): if not self.poisonous: print "Yep! I'm edible." else: print "Don't eat me! I am super poisonous." lemon = Fruit("lemon", "yellow", "sour", False) lemon.description() lemon.is_edible()