Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Thanks!
i is used a lot, as a shorthand for index, that is the position of an item in a sequence.
here we are iterating on the items of the friend list directly, not on their index.
So there is no reason to name the variable i, f as a shorthand for friend is better.
Clean code. Loop variable names doesn't always have to be "i".
'f' from 'friend' probably.
The
if odd
part is an example of Truthy values in Python - you can learn more here:https://www.freecodecamp.org/news/truthy-and-falsy-values-in-python/
(Not an endorsement of freecodecamp, just the first google search result that looked OK).
In this case, it is a shorter version of
if odd == 1
, which in turn is determined by the remainder calculation in the step above.You can also experiment with this in your IDE: for example try:
You should find that only the first statement will print.