bitbybit on Nostr: my_list_to_look_through = [2,7,1,9] number_items_in_list_counter = 0 for x in ...
my_list_to_look_through = [2,7,1,9]
number_items_in_list_counter = 0
for x in my_list_to_look_through:
number_items_in_list_counter +=1
Every time the loop occurs it will iterate over the list to the next item. "x" can be any variable i, j,k, younginter, it's just a place holder. every time the loop executes it will add 1 to the number_items_in_list_counter. In this case it will equal 4.
Another example:
my_list_to_look_through = [2,7,1,9]
empty_container = [ ]
for x in my_list_to_look_through:
empty_container.append(x)
This will take the first item out of my_list_to_look_through and add it into the empty_container list. It will go through the loop, append 2 to empty_container, then 7, then 1, then 9.
Now
Previously defined
my_list_to_look_through = [2,7,1,9]
And our new container has the same
empty_container = [2,7,1,9]
Published at
2024-02-21 00:20:43Event JSON
{
"id": "da18f44af61e1a80e5c7d1ae3ed67b42763f92e2cc179c5f926437c544350d41",
"pubkey": "3e0c0b7ec13c50a4b0bbb7ac8b750ff8ab0f13b80d8ff96e30499fd40cda8a9e",
"created_at": 1708474843,
"kind": 1,
"tags": [
[
"e",
"83d05b46dc76521da8f69bab236cdc568ad2b110495b58862776f6104436c5ea"
],
[
"p",
"5fd693e61a7969ecf5c11dbf5ce20aedac1cea71721755b037955994bf6061bb"
]
],
"content": "my_list_to_look_through = [2,7,1,9]\nnumber_items_in_list_counter = 0\n\nfor x in my_list_to_look_through:\n number_items_in_list_counter +=1\n\nEvery time the loop occurs it will iterate over the list to the next item. \"x\" can be any variable i, j,k, younginter, it's just a place holder. every time the loop executes it will add 1 to the number_items_in_list_counter. In this case it will equal 4.\n\nAnother example:\n\nmy_list_to_look_through = [2,7,1,9]\nempty_container = [ ]\n\nfor x in my_list_to_look_through:\n empty_container.append(x)\n\nThis will take the first item out of my_list_to_look_through and add it into the empty_container list. It will go through the loop, append 2 to empty_container, then 7, then 1, then 9.\n\nNow\nPreviously defined\nmy_list_to_look_through = [2,7,1,9]\n\nAnd our new container has the same\nempty_container = [2,7,1,9]",
"sig": "69983c4041a56db01eda3a0d0f9daa8400992f330a622c398895dbee5a27028e0f0dc827752bcf8b0624a3da54a73ea0cdd78121edbf17696099dd3f55946b96"
}