Quick question - Python


In the for loop attached; how does Python know that “element” refers to a key vs value.

The word element seems random.
I don’t see it defined anywhere as a “key”

What if we wanted to make it refer to value instead (of a key), how can we change this sentence?

Thank you very much!

it is very simple and I will spend 1 minute to write down the answer so you will get it
Step1 .Download for example pycharm or visual studio or you name it
Step2. Install it
Step3. Start testing
Step4. Spend more time testing
finally if u change
for elements in oscars:
for elements in oscars.values():

u will get what u asked
I am sure either way if u spend time testing u will find a lot more by yourself and that will be the moment for you.

1 Like

Hi Kommas,

Thank you very much!

One quick follow up; is the word “element” chosen at random?
I don’t see it defined anywhere.

Thank you very much,

1 Like

yeap you can name it as you want it is a random chosen name.

if we want to extract names from a loop we usually end up writing
for name in …
if we want to extract colors we write
for color in …
That’s the best way to write code and best understand what you want, not only you but the others reading your code too.!!!

1 Like

I deeply appreciate. Thank you Kommas. The Python community is super nice!

1 Like