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

How to add fixed number of items in a list from another list? [closed]

  • Thread starter Thread starter Sahil Khalane
  • Start date Start date
S

Sahil Khalane

Guest
Code:
list1 = [1, 2, 3, 4, 5]
list2 = []

Now I want to add any RANDOM items from list1 to list2

I have used append Function, but the problem is it will add all the numbers in the list1.

Also, the code should not be complex to understand.
<pre><code>list1 = [1, 2, 3, 4, 5]
list2 = []
</code></pre>
<p>Now I want to add any RANDOM items from list1 to list2</p>
<p>I have used append Function, but the problem is it will add all the numbers in the list1.</p>
<p>Also, the code should not be complex to understand.</p>
 

Latest posts

Top