abhi_47
abhi_47

Reputation: 25

I want to convert the R code to python. How to do the below given operation using python?

for_sample <- c("The variance is driven by ", 
                "The majority of the variance is due to ",
                "Driven by ",
                "The key movements were driven by ")

sampled<- sample(for_sample, 2)

I am able to understand that the output will be different every time. I just want to replicate the same operation using python.

Upvotes: 0

Views: 28

Answers (1)

broti
broti

Reputation: 1382

Do this:

import random
for_sample = ["The variance is driven by ",
               "The majority of the variance is due to ",
               "Driven by ",
               "The key movements were driven by "]
sampled = random.sample(for_sample, 2)

Upvotes: 1

Related Questions