tharsitis

tharsitis

Search
Skip to content
  • about

Monthly Archives: January 2021

Python programming
Code Snippets, Uncategorized

Create a list with values from an other list

January 7, 2021 dimitris Leave a comment

Assuming that i have the following list

fruits=['mango','apple','orange','peach'] 

and from this list I want to create a new list randomly selecting specific number of values

then this is how it is being done for two random values of the fruits list

import random
random_fruits = random.choices(fruits, k=2)

which results to

fruits=['mango','peach'] 

listpythonrandom

my wordpress log

Recent Posts

  • Python IDLE in virtual environment
  • Create a list with values from an other list
  • Export Python Evironment Installed Packages
  • Connect to Sqlite3 using python
  • Outlook 2016 Unread and Flagged View

Recent Comments

    Archives

    • February 2021
    • January 2021
    • January 2019
    • November 2018
    • March 2018
    • November 2017
    • June 2017
    • May 2017
    • January 2017
    • March 2016
    • February 2016
    • January 2016
    • December 2015
    • August 2015
    • June 2015
    • March 2015
    • February 2015
    • October 2014
    • July 2014

    Categories

    • Blog Admin
    • Code Snippets
    • Development
    • Hello World!
    • Media Player
    • Monetization
    • Notepad++
    • Photo Processing
    • Photo Shooting
    • Scripts
    • Training
    • Uncategorized
    • Virtualization
    • Web Site Admin
    • windows

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    Proudly powered by WordPress