manual_enumerate.py

Created by 546f6d

Created on November 22, 2024

605 Bytes

EN : This function is used to reproduce the operation of the basic ‘enumerated’ function. This reproduction was created to allow people to better understand the operation of the basic function.

FR : Cette fonction est utilisée pour reproduire le fonctionnement de la fonction ‘enumerated’ de base. Cette reproduction a été créée pour permettre aux gens de mieux comprendre le fonctionnement de la fonction de base.



def manual_enumerate(list:list):
  """
  This function is used to reproduce the operation of the basic enumerated function.
  This reproduction was created to allow people to better understand the operation of the basic function.
  """
  
  new_list = []
  
  n = 0
  for v in list:
    new_list.append((n, v))
    n = n + 1
  
  return new_list


# --- Example of use ---

exemple_list = ["exemple", "hello", "world", "hi"]

result = manual_enumerate(exemple_list)

print(result)
print("\n\n----\n\n")

for i, v in result:
  print("index =", i)
  print("value =", v)
  print("")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.