Skip to content
Advertisement

Tag: python

Remove duplicate value on nested list python

I have a problem here when I want to remove duplicate in a list that has a nested list, how can I remove the duplicate value from list? What I got here from my script, it can remove a duplicate, but the nested list has a different result from what I expect. This is my script: Result: Expected Result: Answer

Find the average length of all words in a sentence

Given a string consisting of words separated by spaces (one or more). Find the average length of all words. Average word length = total number of characters in words (excluding spaces) divided by the number of words. My attempt: But input is incorrect, can you help me? Answer When you’re stuck, one nice trick is to use very verbose variable

Not able to do Insert operation in CRUD

I am making a CRUD of colors with color_name and color_description. While trying to insert the details the error below has be shown: below is the insert and show function that I have tried out model HTML of insert_color HTML of show color I have checked the names assigned and they are matching, so where am I going wrong? Answer

Django csv upload to db works but throws error

I have created an app named customer within a project named Website using django. I have created a csv upload in the admin area which is connected to the Postgres db. However the CSV file is still added to the db but the error screen is displayed. Even more strangely if I a notepad doc as csv containing the data

Continue in if conditional python loop is not working

Results are I was expecting that it would identify the first pattern DS in the first string in list a, then move to next element. However, it proceed to identify DY as well. What am I doing incorrectly? Any help is appreciated. Thanks Answer Try to replace continue with break like this Output: сontinue actually means that you go to

How add value in second row into first row?

I would like to add a new columns from a values of ‘Pr’ in second rows for each value same id and date. Input a: ID Date order Date restock Pr Infos 778005 2022-04-07 11:34:46.0 NaN 87.0;113001.0;00 a 778005 2022-04-07 11:34:46.0 NaN 87.0;113159.0;FC at 7001 2021-12-10 13:50:46.0 2021-12-13 00:00:00.0 87.0;271007.0;BV b 7001 2021-12-10 13:50:46.0 2021-12-13 00:00:00.0 87.0;286005.0;BV bt 778005 2022-05-24

Advertisement