Skip to content
Advertisement

Tag: list

How do I remove a common character from each element in my list?

I’m cleaning up my data after web scraping and the list has n before each element. SP500 = [‘nAAPL’, ‘nMSFT’, ‘nGOOG’, ‘nGOOGL’, ‘nAMZN’, ‘nTSLA’…] How should I go about removing the n from each element? Answer If you know it is always the same pattern, you can use str.removeprefix() available for python 3.9+, in your case: If you know it’s

Check same value in multiple lists [python]

I’ve 5 lists with some Infos saved in like: What i’d like do is check them and create a table like that’s: I’ve no worries to import a new library like pandas or others. I tried to use some nested For loop to check if there’s double values in each list and if was true, add it, but i’ve many

Python add missing element into list

I have a list with day of a month as key and i want to add all missing day with 0 as value. This is a sample : And I looking for something like this : What is the better way to did it. This is my code : Answer You could simply make a run with numbers varying from

How do I compare two letters or values in two different lists?

I am making a program that has two lists (in Python), and each list contains 5 different letters. How do I make it so that any index number I choose for both lists gets compared and uppercase a letter if the condition is true? If the first two values in the list are the same (in my case a lowercase

Advertisement