fruits = {"Apple": "Red", "Raspberry": "Red", "Strawberry": "Red", "Orange": "Orange","Banana": "Yellow", "Lemon": "Yellow", "Pineapple": "Yellow", "Avocado": "Green", "Lime": "Green", "Melon": "Green", "Pear": "Green", "Blueberry": "Blue", "Huckleberry": "Blue", "Plum": "Purple", "Grape": "Purple", "Maquiberry": "Purple"} colour_of_fruit = lambda fruit : fruits[fruit] if fruit in fruits else "Not a fruit!" ''' almost oneliner... I am hungry. I'll have a fruit. Thanks for creating the dictionary (map) by the way. Instead of defining the map fruits, I could just copy that map and put it wherever I used it and then, after deleting the comments, it would be a perfect oneliner XD. I will leave this chance for someone else XD. '''
fruit_colours = {"Red": ("Apple", "Raspberry", "Strawberry"),"Orange": ("Orange",),"Yellow": ("Banana", "Lemon", "Pineapple"),"Green": ("Avocado", "Lime", "Melon", "Pear"),"Blue": ("Blueberry", "Huckleberry"),"Purple": ("Plum", "Grape", "Maquiberry")}fruits = {f: cfor c, fs in fruit_colours.items()for f in fs}def colour_of_fruit(fruit: str) -> str:"""Returns the color of given fruit."""return fruits.get(fruit, "Not a fruit!")- fruits = {"Apple": "Red", "Raspberry": "Red", "Strawberry": "Red", "Orange": "Orange","Banana": "Yellow", "Lemon": "Yellow", "Pineapple": "Yellow", "Avocado": "Green", "Lime": "Green", "Melon": "Green", "Pear": "Green", "Blueberry": "Blue", "Huckleberry": "Blue", "Plum": "Purple", "Grape": "Purple", "Maquiberry": "Purple"}
- colour_of_fruit = lambda fruit : fruits[fruit] if fruit in fruits else "Not a fruit!"
- '''
- almost oneliner... I am hungry. I'll have a fruit.
- Thanks for creating the dictionary (map) by the way.
- Instead of defining the map fruits, I could just copy
- that map and put it wherever I used it and then, after
- deleting the comments, it would be a perfect oneliner XD.
- I will leave this chance for someone else XD.
- '''
theletterh = lambda howmuchh : "H" * howmuchh
def theletterh(howmuchh=1):for row in range(7):for col in range(5):if col in [0, 4] or (row in [3] and col in [1, 2, 3]):print('H', end='')else:print(end=' ')print()print()return 'H' * howmuchh#H return and H print (H😀😃😁)- theletterh = lambda howmuchh : "H" * howmuchh