OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Creating a new list from the existing one

  • Thread starter Thread starter Reaper Furry
  • Start date Start date
R

Reaper Furry

Guest
I have a python list as seen

base-list

Code:
['Year Built 2016', 'Floor 7', 'Year Built 2019', 'Floor 23', 'Year Built 2015', 'Floor 12', 'Year Built 2006', 'Floor 8', 'Year Built 2015', 'Floor 23', 'Year Built 2015', 'Floor 28', 'Year Built 2008', 'Floor 19', 'Year Built 2014', 'Floor 3', 'Year Built 2019', 'Floor 33', 'Year Built 1997', 'Floor 31', 'Year Built 2015', 'Floor 17', 'Year Built 2015', 'Floor 33', 'Year Built 1996', 'Floor 8', 'Year Built 2009', 'Floor 3', 'Year Built 2008', 'Floor 13', 'Year Built 2006', 'Floor 30', 'Year Built 2018', 'Floor 2', 'Year Built 2008', 'Floor 34', 'Year Built 2019', 'Floor 23', 'Year Built 2022', 'Floor 31', 'Year Built 2006', 'Floor 14', 'Year Built 2021', 'Floor 7', 'Year Built 2015', 'Floor 36', 'Year Built 2015', 'Floor 10', 'Year Built 2015', 'Floor 32', 'Year Built 2015', 'Floor 26', 'Year Built 2019', 'Floor 40', 'Year Built 2015', 'Floor 8', 'Year Built 2015', 'Floor 6']

from this list I wish to make new 2 seperate list. one for only 'Year built' and one for only 'Floor'. anyone can give me advince on how to do this?

I have try this method

year_built_list = [i for i in base_list if base_list.startwith('Y')]

*year_built_list is the new list I tried to create

but it's not working
<p>I have a python list as seen</p>
<p>base-list</p>
<pre><code>['Year Built 2016', 'Floor 7', 'Year Built 2019', 'Floor 23', 'Year Built 2015', 'Floor 12', 'Year Built 2006', 'Floor 8', 'Year Built 2015', 'Floor 23', 'Year Built 2015', 'Floor 28', 'Year Built 2008', 'Floor 19', 'Year Built 2014', 'Floor 3', 'Year Built 2019', 'Floor 33', 'Year Built 1997', 'Floor 31', 'Year Built 2015', 'Floor 17', 'Year Built 2015', 'Floor 33', 'Year Built 1996', 'Floor 8', 'Year Built 2009', 'Floor 3', 'Year Built 2008', 'Floor 13', 'Year Built 2006', 'Floor 30', 'Year Built 2018', 'Floor 2', 'Year Built 2008', 'Floor 34', 'Year Built 2019', 'Floor 23', 'Year Built 2022', 'Floor 31', 'Year Built 2006', 'Floor 14', 'Year Built 2021', 'Floor 7', 'Year Built 2015', 'Floor 36', 'Year Built 2015', 'Floor 10', 'Year Built 2015', 'Floor 32', 'Year Built 2015', 'Floor 26', 'Year Built 2019', 'Floor 40', 'Year Built 2015', 'Floor 8', 'Year Built 2015', 'Floor 6']
</code></pre>
<p>from this list I wish to make new 2 seperate list. one for only 'Year built' and one for only 'Floor'. anyone can give me advince on how to do this?</p>
<p>I have try this method</p>
<p>year_built_list = [i for i in base_list if base_list.startwith('Y')]</p>
<p>*year_built_list is the new list I tried to create</p>
<p>but it's not working</p>
 

Latest posts

Top