Day 33: 100 Days of Code: Dynamic Lists

preview_player
Показать описание

00:00 Dynamic lists
04:00 Removing items from a list
06:14 Common errors
10:14 Fix my code
10:33 Day 33 challenge
11:54 Share your code
12:07 Next up
Рекомендации по теме
Комментарии
Автор

i tired to do the challege in 10 mins and failelled i forgor to add a while true loop abd how to spel aparently


e. the code i did in 10 mins

#challenge time
print("todo list")
todolist = []
def view():
print(todolist)
def add():
item = input("what do you want to add?")
todolist.append(item)
print(todolist)
def edit():
print("what item have you completed")
item = input(">")
todolist.remove(item)
print("\033[036m")
while True:
print("\033[036m")
select = input("what do you want to do 'add' or 'edit' or 'view'.")
if select == "view":
view()
elif select == "add":
add()
print("\033[033m")
if select == "edit":
edit()
print(f"{select:^50}")

MarcoAlmond-ColomerYear
Автор

print("To-Do List Manager\n")

todoList = []

def printList():
print()
for item in todoList:
print(item)
print()

while True:
task = input("Do you want to view, add or edit the todo list?\n")
if task == "add":
print()
item = input("What do you want to add?: \n")
todoList.append(item)
print()
elif task == "view":
print()
printList()
else:
print()
if task == "edit":
printList()
edit1 = input("Do you want to change an existing item or remove it? (select either change or remove): ")
if edit1 == "change":
item = input("Which item to change?: ")
if item in todoList:
todoList.remove(item)
item1 = input("replace above with: ")
todoList.append(item1)
printList()
else:
print(f"{item} is not in the list")
elif edit1 == "remove":
item1 = input("which item to remove?: ")
if item1 in todoList:
todoList.remove(item1)
printList()
else:
print(f"{item1} is not in the list")

else:
print(f"{task} is not in the list")

abhi
Автор

lista = []



def listado():
for i in lista:
print(i)
inicio_()

def inicio_():
inicio = input("¿Deseas ver (v), añadir (a) o editar (e) la lista? ")
if inicio == "v":
listado()
elif inicio == "a":
add = input("Añade actividad: ")
lista.append(add)
inicio_()
elif inicio == "e":
remover = input("Remover actividad: ")
if remover in lista:
lista.remove(remover)
inicio_()
else:
print(f"{remover} no se encuentra en el listado")
inicio_()
elif inicio == "v":
listado()
else:
inicio_()

print("Lista de actividades")
inicio_()

manliofaviomascarenosigala
Автор

todo=[]
print("To-Do List Manager")
print("Here are the
while True:
menu=input("What do you want to do?").upper()

if menu=="VIEW":
if todo==[]:
print("Your list is empty.")
continue
else:
print()
for i in todo:
print(i)
print()
if menu=="ADD":
item=input("What do you want to add in list?")
todo.append(item)
if menu=="REMOVE":
item=input("What do you want to remove in list?")
if item in todo:
todo.remove(item)
else:
print("There is not such thing in the list.")
continue
if menu=="EXIT":
break

lyrica
Автор

This one was fun to figure out!

import os, time

myList = []
title = "\033[35m *** \033[32mTo Do List Manager! \033[35m***"

def taskViewer():
time.sleep(1)
os.system("clear")
print(f"{title: ^70}\n")
number = 1
for item in myList:
print(f"\033[0m{number}: \033[31m{item} ")
print()
number += 1
time.sleep(0.3)
print("\033[0m")
input("press enter to go back: ")

def addItem():
item = input("What do we Add? ").capitalize()
print()
if item not in myList:
myList.append(item)
print(f"{item} has been added to your list!")
return
else:
print(f"{item} was already on your list!")
return

def editItem():
how = input("Press 1 to remove, press 2 to replace: ")
print()
if how == "1":
item = input("What do you want to remove? ").capitalize()
print()
if item in myList:
myList.remove(item)
print(f"{item} has been removed from your list!\n")
else:
print(f"{item} was not on your To Do List.. \n")
elif how == "2":
item = input("What do you want to replace? ").capitalize()
print()
if item in myList:
newItem = input("What should we change it too? ").capitalize()
print()
myList.remove(item)
myList.append(newItem)
print("Your wish has been fulfilled! \n")
else:
print(f"{item} was not on your To Do List buddy.. \n")
else:
print("I asked you to press 1 or 2.. \n")



while True:
time.sleep(1)
os.system("clear")
print(f"{title: ^70}\n")
task = input("\033[0mView, Add, or Edit? ").lower()

if task == "add" or task == "ad":
addItem()
elif task == "edit" or task == "edi":
editItem()
elif task == "view" or task == "vie":
taskViewer()
else:
print("That was not a valid option.. \n")

VinnieG-
Автор

in the common error section the answer is wrong it should say

item = input ("What do you want to remove?: ")


it instead says:

item = ("What do you want to remove?: ")

thefigureshow
Автор

bro i cant believe i have only completed 1/3 😭😭

Morganjunction
Автор

Heres my code for today's challenge:
Space = " "
print(Space, "\033[0;34m", "ToDo List Manager", "\033[0;37m")
print()
ToDoList = []

def ListManager(Manager):
Manager = Manager.lower()
if Manager == "view":
item = 0
print()
for item in ToDoList:
print(item)
print()
elif Manager == "add":
Add = input("What do you want to add? Answer: ")
ToDoList.append(Add)
elif Manager == "edit":
Check = input("Do you want to remove, move items or clear the list? Answer: ")
Check = Check.lower()
if Check == "remove":
Remove = input("What do you want to remove? Answer: ")
if Remove in ToDoList:
ToDoList.remove(Remove)
else:
print(f"There isn't any item named {Remove} in the list. Please try again.")
elif Check == "clear the list" or Check == "clear" or Check == "clear all":
ToDoList.clear()
elif Check == "move items" or Check == "move":
Move = input("What do you want to move? Answer: ")
if Move in ToDoList:
ToDoList.remove(Move)
MoveItemToLine = input("What line do you want to move the item to? Answer: ")
- 1, Move)
else:
print(f"There isn't any item named {Move} in the list. Please try again.")
else:
print("Please try again.")

while True:
ListManager(input("Do you want to view, add, or edit your to do list? Answer: "))

phiphaminh
Автор

import time, os
Todolist = []
def printlist():
for item in Todolist:
print(item)
while True:
print("To Do List Manager:")
ask = input("Do you want to View, add, edit or exit your to do list?\n")
if ask == "view":
printlist()
time.sleep(15)
os.system("clear")
elif ask == "add":
item = input("What do you want to add?: ")
Todolist.append(item)
os.system("clear")
elif ask == "edit":
item = input("What do you want to edit?: ")
Todolist.remove(item)
os.system("clear")
else:
exit()

tounsimed
Автор

CODE:

to_do_list = []

def view_list():

for i in to_do_list:
print(f'{i: ^18}')
return

def to_do_lists():
command = input('Enter the command :')
if command == 'view' :
print(view_list())
elif command == 'add':
add_item = input('Add the item to the list :')
to_do_list.append(add_item)
print()
print(view_list())
elif command == 'delete':
remove_item = input('Delete the item :')
if remove_item in to_do_list:

print()
print(view_list())
else:
print(f'{remove_item} is not in the to-do-list')
else:
print('Enter a valid command')

MohanakumarThangaraju
Автор

That time of day again

import os, time

List = []

def printList():
print()
for item in List:
print(item)
print()

while True:
menu = input("Le To Do List!\n You viewing, adding or editing? (view/add/edit)\n ")
if menu == "view":
printList()
elif menu == "add":
item = input("What else we doin 2day?: ")
List.append(item)
print(f"{item} was added to the list")
elif menu == "edit":
item = input("What we getting rid of chief? ")
if item in List:
List.remove(item)
print(f"{item} is no longer on the to do list")
else:
print(f"\n{item} was not in the list")
printList()
time.sleep(2)
os.system("clear")

simonm-m
Автор

todolist_base =[]
def todolist_func():
for item in todolist_base:
print(item)
print()

while True:

list_action = input("VIEW, ADD, OR EDIT TODO-LIST: ").lower()

if list_action == "add":
add = input("What would you like to add? ")
todolist_base.append(add)
print(f"You added {add}.")
elif list_action == "view":
for item in todolist_base:
print(item, end=' ')
print()
elif list_action == "edit":
edit = input("Which activity have you completed?: ")
if edit in todolist_base:
print(f"You completed {edit}.")
todolist_base.remove(edit)
edit2 = input("Edit again?: ").lower()
if edit2 == "yes" or edit2 == "edit":
edit3 = input("Which activity have you completed?: ")
todolist_base.remove(edit3)
print(f"You completed {edit3}.")


elif edit not in todolist_base:
print(f"{edit} isn't in the list. Please try again.")

else:
print(f"{list_action} isn't a function. Try again.")
continue
todolist_func()

atomix
Автор

Here's mine. @davidatreplit I couldn't figure out how to add the ability to edit an item in the way I've done the code, instead of having to remove it first then add it back, even after re-watching Day 32.

import os
import time

green = "\033[32m"
default = "\033[0m"
yellow = "\033[33m"
red = "\033[31m"
title = "ToDo List Manager"
toDoList = []


print()
time.sleep(1)

print(f"{red}Please Note: You must have items added to your list before you can view it. If you try to view your list before adding items, it will clear the screen and end the program.{default}")
print()
time.sleep(1)

def printList():
print()
for item in toDoList:

print()
time.sleep(1)

while True:
menu = input("Would you like to View, Add or Edit items on your list?: ")
if menu == "view":

time.sleep(1)
print()
os.system("clear")
time.sleep(1)
printList()
break
print()
elif menu == "add":

print()
time.sleep(1)
item = input("What would you like to add?: ")
toDoList.append(item)
elif menu == "edit":
print(f"{red}Edit{default}")
print()
print(f"{red}Please Note: To edit an item, it removes the item from the list and then you must re-add another item to insert it into the list.{default}")
print()
time.sleep(1)
item = input("What would you like to edit?: ")
print()
time.sleep(1)
if item in toDoList:
toDoList.remove(item)
else:
print(f"Sorry, '{item}' is not in the list and can't be edited")
print()
time.sleep(1)
continue
printList()

RichOnStream