Bunch, Dictionary & Bunch Object

Aishwarya A
1 min readNov 30, 2023

--

Imagine you have a bunch of toys. Each toy has its own name, like Teddy, Dolly, and Robot. Now, you want to remember which toy is your favorite. So, you have a special list where you write down the names of your favorite toys next to their pictures. In Python, we have something similar called a “dictionary.” A dictionary is like your list of favorite toys. It’s a way to store information about different things.

Bunch (Not a real thing in Python, just for fun!):

# Your bunch of favorite toys
teddy = “Fluffy Bear”
dolly = “Cute Doll”
robot = “Funny Robot”
print(“My favorite teddy is”, teddy)
print(“My favorite dolly is”, dolly)
print(“My favorite robot is”, robot)

Dictionary (A real thing in Python!):

# Your dictionary of favorite toys
favorites = { “teddy”: “Fluffy Bear”,
“dolly”: “Cute Doll”,
“robot”: “Funny Robot”}
print(“My favorite teddy is”, favorites[“teddy”])
print(“My favorite dolly is”, favorites[“dolly”])
print(“My favorite robot is”, favorites[“robot”])

Bunch Object: The term “bunch” doesn’t have a specific meaning in Python on its own. However, sometimes people use it informally to describe an object that can hold a bunch of attributes or properties.

Syntax:

--

--

No responses yet