hey there folks
I am working through ‘Conditional statements’ and I don’t quite under why we sometimes need to use: ‘app’ and sometimes ‘row’
‘’‘for app in apps_data’’’
‘’‘for row in apps_data’’’
how do we know which to use? so that the code works?
thanks a mil folks
It doesn’t really matter if you use
row or even
banana. The choice you make largely depends on what makes sense to you (makes the code readable and easier to think through). I have a few habits I’ve picked up over time when working with loops. When I am using loops to go through a list of lists (like
apps_data), I tend to always use
row because it reminds me that I’m looping through the rows. If I’m looping through a single list, I may use
item or a more descriptive variable depending on what I know is in the list. If I’m looping through a list of index numbers, I tend to use
j for loops within loops). For dictionaries I tend to use
key. No matter which way you go with it, it doesn’t affect the functionality, because it’s just a placeholder for a value, so go for readability.
thanks a mil for clearing this up for me