二手产品经理

二手产品经理

THIS IS RENO

Array - 34 days - Learn Python online for 100 days

Records#

  1. Continue learning arrays today. Defining repetitive and reusable code as functions can improve the aesthetics of the code.
  2. Create a numbered list for the array.
    1. Method 1. Define a counter when printing, and increase it by 1 each time in the loop.
    2. Method 2. Use the index of the for loop with range.
  3. Today's exercise is to add option 4 to the case. It's relatively simple and not difficult.
import os, time
listOfEmail = []

def prettyPrint():
  os.system("clear") 
  print("listofEmail") 
  print()
  for index in range(len(listOfEmail)): # len counts how many items in a list
    print(f"{index}: {listOfEmail[index]}") 
  time.sleep(1)

def spamming():
  os.system("clear")
  print("SPAMMING")
  print()
  for i in range(10):
    os.system("clear")
    print(f"spamming {i}")
    time.sleep(2)
    


while True:
  print("SPAMMER Inc.")
  menu = input("1. Add email\n2: Remove email\n3. Show emails\n4. Get SPAMMING\n> ")
  if menu == "1":
    email = input("Email > ")
    listOfEmail.append(email)
  elif menu =="2":
    email = input ("Email > ")
    if email in listOfEmail:
      listOfEmail.remove(email)
  elif menu == "3":
    prettyPrint() 
  elif menu == "4":
    spamming()
  time.sleep(1)
  os.system("clear")

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.