Is it okay not to write a better code?(instead of trying to understand the “better code”) /u/Yubion Python Education

(btw shitposing but I really need to know)

So this is my code:

def clear_list(to_do_list, task_type): match task_type: case "all" : to_do_list.clear() case "checked": remaining_tasks = [] for index, x in enumerate(to_do_list): if not to_do_list[index].get("status") == "33[32m" + " Checked " + "33[39m": remaining_tasks.append(x) to_do_list.clear() for y in remaining_tasks: to_do_list.append(y) 

And someone(ChatGPT, hear me out, I only asked him “is this code consider as DRY:“)

So that someone said the code below is better than mine:

def clear_list(to_do_list, task_type): if task_type == "all": to_do_list.clear() elif task_type == "checked": to_do_list[:] = [task for task in to_do_list if not is_task_checked(task)] def is_task_checked(task): # Check for the "Checked" status (returns True if the task is checked). return task.get("status") == "33[32m Checked 33[39m" 

I dont know man, I tried my best to solve the code for reasonable hours and someone came at me(I actually went to him but wtv) and said that my code is fucking shit compare to his. The point is can I just keep my code, or should I try to learn what that someone said because that how learning suppose to work?

submitted by /u/Yubion
[link] [comments]

​r/learnpython (btw shitposing but I really need to know) So this is my code: def clear_list(to_do_list, task_type): match task_type: case “all” : to_do_list.clear() case “checked”: remaining_tasks = [] for index, x in enumerate(to_do_list): if not to_do_list[index].get(“status”) == “33[32m” + ” Checked ” + “33[39m”: remaining_tasks.append(x) to_do_list.clear() for y in remaining_tasks: to_do_list.append(y) And someone(ChatGPT, hear me out, I only asked him “is this code consider as DRY:”) So that someone said the code below is better than mine: def clear_list(to_do_list, task_type): if task_type == “all”: to_do_list.clear() elif task_type == “checked”: to_do_list[:] = [task for task in to_do_list if not is_task_checked(task)] def is_task_checked(task): # Check for the “Checked” status (returns True if the task is checked). return task.get(“status”) == “33[32m Checked 33[39m” I dont know man, I tried my best to solve the code for reasonable hours and someone came at me(I actually went to him but wtv) and said that my code is fucking shit compare to his. The point is can I just keep my code, or should I try to learn what that someone said because that how learning suppose to work? submitted by /u/Yubion [link] [comments] 

(btw shitposing but I really need to know)

So this is my code:

def clear_list(to_do_list, task_type): match task_type: case "all" : to_do_list.clear() case "checked": remaining_tasks = [] for index, x in enumerate(to_do_list): if not to_do_list[index].get("status") == "33[32m" + " Checked " + "33[39m": remaining_tasks.append(x) to_do_list.clear() for y in remaining_tasks: to_do_list.append(y) 

And someone(ChatGPT, hear me out, I only asked him “is this code consider as DRY:“)

So that someone said the code below is better than mine:

def clear_list(to_do_list, task_type): if task_type == "all": to_do_list.clear() elif task_type == "checked": to_do_list[:] = [task for task in to_do_list if not is_task_checked(task)] def is_task_checked(task): # Check for the "Checked" status (returns True if the task is checked). return task.get("status") == "33[32m Checked 33[39m" 

I dont know man, I tried my best to solve the code for reasonable hours and someone came at me(I actually went to him but wtv) and said that my code is fucking shit compare to his. The point is can I just keep my code, or should I try to learn what that someone said because that how learning suppose to work?

submitted by /u/Yubion
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *